Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 191332 Details for
Bug 339478
[1.7][compiler] support for diamond case
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
proposed fix v1.1
patch339478.txt (text/plain), 43.11 KB, created by
Ayushman Jain
on 2011-03-16 14:47:07 EDT
(
hide
)
Description:
proposed fix v1.1
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-03-16 14:47:07 EDT
Size:
43.11 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v >retrieving revision 1.225.2.10 >diff -u -r1.225.2.10 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 1 Mar 2011 05:58:47 -0000 1.225.2.10 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 16 Mar 2011 18:43:27 -0000 >@@ -1373,6 +1373,8 @@ > int InvalidDisjunctiveTypeReferenceSequence = Internal + TypeRelated + 873; > /** @since 3.7 */ > int AutoManagedResourceNotBelow17 = Syntax + Internal + 874; >+ /** @since 3.7 */ >+ int InvalidUsageOfDiamondConstruct = Syntax + TypeRelated + 875; > /** > * External problems -- These are problems defined by other plugins > */ >Index: compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java,v >retrieving revision 1.77.2.3 >diff -u -r1.77.2.3 LocalDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 8 Mar 2011 17:20:09 -0000 1.77.2.3 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 16 Mar 2011 18:43:28 -0000 >@@ -157,7 +157,7 @@ > } > > public void resolve(BlockScope scope) { >- >+ boolean isCompliant17 = scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_7; > // create a binding and add it to the scope > TypeBinding variableType = this.type.resolveType(scope, true /* check bounds*/); > >@@ -171,6 +171,10 @@ > scope.problemReporter().variableTypeCannotBeVoidArray(this); > return; > } >+ if (isCompliant17 && variableType.isParameterizedType() && (this.type.bits & ASTNode.IsDiamond) != 0) { >+ scope.problemReporter().incorrectArityForParameterizedType(this.type, variableType.original(), ((ParameterizedTypeBinding)variableType).arguments); >+ return; >+ } > } > > Binding existingVariable = scope.getBinding(this.name, Binding.VARIABLE, this, false /*do not resolve hidden field*/); >@@ -207,12 +211,17 @@ > } > } else { > this.initialization.setExpectedType(variableType); >+ boolean isDiamond = false; > TypeBinding initializationType = this.initialization.resolveType(scope); >+ if (this.initialization instanceof AllocationExpression) { >+ if (isCompliant17 && (((AllocationExpression) this.initialization).type.bits & ASTNode.IsDiamond) != 0) >+ isDiamond = true; >+ } > if (initializationType != null) { > if (variableType != initializationType) // must call before computeConversion() and typeMismatchError() > scope.compilationUnitScope().recordTypeConversion(variableType, initializationType); > if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, variableType) >- || initializationType.isCompatibleWith(variableType)) { >+ || initializationType.isCompatibleWith(variableType, isDiamond)) { > this.initialization.computeConversion(scope, variableType, initializationType); > if (initializationType.needsUncheckedConversion(variableType)) { > scope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, variableType); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java,v >retrieving revision 1.54.2.1 >diff -u -r1.54.2.1 ParameterizedSingleTypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 25 Jan 2011 20:33:00 -0000 1.54.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 16 Mar 2011 18:43:28 -0000 >@@ -90,6 +90,7 @@ > * No need to check for reference to raw type per construction > */ > private TypeBinding internalResolveType(Scope scope, ReferenceBinding enclosingType, boolean checkBounds) { >+ boolean isCompliant17 = scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_7; > // handle the error here > this.constant = Constant.NotAConstant; > if ((this.bits & ASTNode.DidResolve) != 0) { // is a shared type reference which was already resolved >@@ -222,8 +223,18 @@ > } > // if missing generic type, and compliance >= 1.5, then will rebuild a parameterized binding > } else if (argLength != typeVariables.length) { // check arity >- scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes); >- return null; >+ if(isCompliant17 && argLength == 0) { >+ if ((this.bits & ASTNode.IsDiamond) ==0) { >+ scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes); >+ return null; >+ } >+ // argLength = 0 ok if its the diamond case for compliance >= 1.7 >+ // also no need to check bounds for such a case >+ checkBounds = false; >+ } else { >+ scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes); >+ return null; >+ } > } else if (!currentType.isStatic()) { > ReferenceBinding actualEnclosing = currentType.enclosingType(); > if (actualEnclosing != null && actualEnclosing.isRawType()){ >Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v >retrieving revision 1.101.2.1 >diff -u -r1.101.2.1 QualifiedAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 5 Mar 2011 18:12:56 -0000 1.101.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 16 Mar 2011 18:43:28 -0000 >@@ -272,6 +272,11 @@ > receiverType = scope.enclosingSourceType(); > } else { > receiverType = this.type.resolveType(scope, true /* check bounds*/); >+ boolean isCompliant17 = scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_7; >+ if (isCompliant17 && this.anonymousType != null && (this.type.bits & ASTNode.IsDiamond) != 0) { >+ scope.problemReporter().invalidUsageOfDiamondConstruct(this.type); >+ return null; >+ } > checkParameterizedAllocation: { > if (receiverType == null || !receiverType.isValidBinding()) break checkParameterizedAllocation; > if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>() >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java,v >retrieving revision 1.140.2.4 >diff -u -r1.140.2.4 ReferenceBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 14 Feb 2011 06:33:10 -0000 1.140.2.4 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 16 Mar 2011 18:43:29 -0000 >@@ -1005,6 +1005,18 @@ > * In addition to improving performance, caching also ensures there is no infinite regression > * since per nature, the compatibility check is recursive through parameterized type arguments (122775) > */ >+public boolean isCompatibleWith(TypeBinding otherType, boolean isDiamondCase) { >+ if (isDiamondCase) { >+ if (this.erasure() == otherType.erasure()) >+ return true; >+ } >+ return isCompatibleWith(otherType); >+} >+/** >+ * Answer true if the receiver type can be assigned to the argument type (right) >+ * In addition to improving performance, caching also ensures there is no infinite regression >+ * since per nature, the compatibility check is recursive through parameterized type arguments (122775) >+ */ > public boolean isCompatibleWith(TypeBinding otherType) { > if (otherType == this) > return true; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java,v >retrieving revision 1.113 >diff -u -r1.113 TypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 24 Nov 2010 04:51:11 -0000 1.113 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 16 Mar 2011 18:43:33 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -1183,4 +1183,8 @@ > public TypeVariableBinding[] typeVariables() { > return Binding.NO_TYPE_VARIABLES; > } >+ >+public boolean isCompatibleWith(TypeBinding variableType, boolean isDiamond){ >+ return isCompatibleWith(variableType); >+} > } >Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v >retrieving revision 1.422.2.13 >diff -u -r1.422.2.13 Parser.java >--- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 9 Mar 2011 13:26:29 -0000 1.422.2.13 >+++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 16 Mar 2011 18:43:48 -0000 >@@ -8893,7 +8893,8 @@ > parameterizedSingleTypeReference.sourceEnd = this.endStatementPosition; > } > if (isDiamond) { >- parameterizedSingleTypeReference.bits |= ASTNode.IsDiamond; >+ if (parameterizedSingleTypeReference.dimensions == 0) >+ parameterizedSingleTypeReference.bits |= ASTNode.IsDiamond; > } > return parameterizedSingleTypeReference; > } else { >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.430.2.13 >diff -u -r1.430.2.13 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 1 Mar 2011 05:58:47 -0000 1.430.2.13 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 16 Mar 2011 18:44:01 -0000 >@@ -3861,6 +3861,15 @@ > annotationTypeDeclaration.sourceStart, > annotationTypeDeclaration.sourceEnd); > } >+public void invalidUsageOfDiamondConstruct(ASTNode typeRef) { >+ //int i = 1; >+ this.handle( >+ IProblem.InvalidUsageOfDiamondConstruct, >+ NoArgument, >+ NoArgument, >+ typeRef.sourceStart, >+ typeRef.sourceEnd); >+} > public void invalidUsageOfEnumDeclarations(TypeDeclaration enumDeclaration) { > this.handle( > IProblem.InvalidUsageOfEnumDeclarations, >Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v >retrieving revision 1.262.2.10 >diff -u -r1.262.2.10 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 1 Mar 2011 05:58:47 -0000 1.262.2.10 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 16 Mar 2011 18:44:02 -0000 >@@ -636,6 +636,7 @@ > 872 = The resource {0} of a try-with-resources statement cannot be assigned > 873 = The exception {0} is already caught by the exception {1} > 874 = Resource specification not allowed here for source level below 1.7 >+875 = Empty type argument list cannot be used in anonymous class declaration > > ### ELABORATIONS > ## Access restrictions >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java,v >retrieving revision 1.40.2.6 >diff -u -r1.40.2.6 CompilerInvocationTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 1 Mar 2011 05:58:30 -0000 1.40.2.6 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 16 Mar 2011 18:44:12 -0000 >@@ -50,7 +50,7 @@ > // Only the highest compliance level is run; add the VM argument > // -Dcompliance=1.4 (for example) to lower it if needed > static { >-// TESTS_NAMES = new String[] { "test003_task_tags_options" }; >+ TESTS_NAMES = new String[] { "test012_compiler_problems_tuning" }; > // TESTS_NUMBERS = new int[] { 1 }; > // TESTS_RANGE = new int[] { 1, -1 }; > // TESTS_RANGE = new int[] { 1, 2049 }; >@@ -422,8 +422,8 @@ > expectedProblemAttributes.put("DuplicateParameterizedMethods", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("DuplicateSuperInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); > expectedProblemAttributes.put("DuplicateTargetInTargetAnnotation", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); >- expectedProblemAttributes.put("DuplicateTypes", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); > expectedProblemAttributes.put("DuplicateTypeVariable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); >+ expectedProblemAttributes.put("DuplicateTypes", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); > expectedProblemAttributes.put("EmptyControlFlowStatement", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM)); > expectedProblemAttributes.put("EnclosingInstanceInConstructorCall", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); > expectedProblemAttributes.put("EndOfSource", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); >@@ -452,9 +452,9 @@ > expectedProblemAttributes.put("FieldTypeNotVisible", DEPRECATED); > expectedProblemAttributes.put("FinalBoundForTypeVariable", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE)); > expectedProblemAttributes.put("FinalFieldAssignment", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); >- expectedProblemAttributes.put("FinallyMustCompleteNormally", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM)); > expectedProblemAttributes.put("FinalMethodCannotBeOverridden", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("FinalOuterLocalAssignment", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); >+ expectedProblemAttributes.put("FinallyMustCompleteNormally", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM)); > expectedProblemAttributes.put("ForbiddenReference", new ProblemAttributes(CategorizedProblem.CAT_RESTRICTION)); > expectedProblemAttributes.put("GenericConstructorTypeArgumentMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); > expectedProblemAttributes.put("GenericMethodTypeArgumentMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); >@@ -583,6 +583,7 @@ > expectedProblemAttributes.put("InvalidUnicodeEscape", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); > expectedProblemAttributes.put("InvalidUsageOfAnnotationDeclarations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); > expectedProblemAttributes.put("InvalidUsageOfAnnotations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); >+ expectedProblemAttributes.put("InvalidUsageOfDiamondConstruct", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); > expectedProblemAttributes.put("InvalidUsageOfEnumDeclarations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); > expectedProblemAttributes.put("InvalidUsageOfForeachStatements", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); > expectedProblemAttributes.put("InvalidUsageOfStaticImports", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); >@@ -646,9 +647,9 @@ > expectedProblemAttributes.put("JavadocNotVisibleField", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("JavadocNotVisibleMethod", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("JavadocNotVisibleType", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); >+ expectedProblemAttributes.put("JavadocParameterMismatch", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("JavadocParameterizedConstructorArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("JavadocParameterizedMethodArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); >- expectedProblemAttributes.put("JavadocParameterMismatch", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericConstructor", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericMethod", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("JavadocUndefinedConstructor", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); >@@ -662,16 +663,16 @@ > expectedProblemAttributes.put("JavadocUsingDeprecatedField", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("JavadocUsingDeprecatedMethod", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("JavadocUsingDeprecatedType", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); >- expectedProblemAttributes.put("LocalVariableCannotBeNull", DEPRECATED); > expectedProblemAttributes.put("LocalVariableCanOnlyBeNull", DEPRECATED); >+ expectedProblemAttributes.put("LocalVariableCannotBeNull", DEPRECATED); > expectedProblemAttributes.put("LocalVariableHidingField", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT)); > expectedProblemAttributes.put("LocalVariableHidingLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT)); > expectedProblemAttributes.put("LocalVariableIsNeverUsed", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE)); > expectedProblemAttributes.put("LocalVariableMayBeNull", DEPRECATED); > expectedProblemAttributes.put("MaskedCatch", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM)); > expectedProblemAttributes.put("MethodButWithConstructorName", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE)); >- expectedProblemAttributes.put("MethodCanBeStatic", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE)); > expectedProblemAttributes.put("MethodCanBePotentiallyStatic", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE)); >+ expectedProblemAttributes.put("MethodCanBeStatic", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE)); > expectedProblemAttributes.put("MethodMissingDeprecatedAnnotation", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE)); > expectedProblemAttributes.put("MethodMustOverride", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("MethodMustOverrideOrImplement", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); >@@ -739,9 +740,9 @@ > expectedProblemAttributes.put("PackageCollidesWithType", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); > expectedProblemAttributes.put("PackageIsNotExpectedPackage", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); > expectedProblemAttributes.put("ParameterAssignment", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE)); >+ expectedProblemAttributes.put("ParameterMismatch", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("ParameterizedConstructorArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); > expectedProblemAttributes.put("ParameterizedMethodArgumentTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); >- expectedProblemAttributes.put("ParameterMismatch", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("ParsingError", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); > expectedProblemAttributes.put("ParsingErrorDeleteToken", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); > expectedProblemAttributes.put("ParsingErrorDeleteTokens", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); >@@ -789,6 +790,9 @@ > expectedProblemAttributes.put("StaticMemberOfParameterizedType", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); > expectedProblemAttributes.put("StaticMethodRequested", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("StringConstantIsExceedingUtf8Limit", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); >+ expectedProblemAttributes.put("SuperInterfaceMustBeAnInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); >+ expectedProblemAttributes.put("SuperInterfacesCollide", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); >+ expectedProblemAttributes.put("SuperTypeUsingWildcard", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); > expectedProblemAttributes.put("SuperclassAmbiguous", DEPRECATED); > expectedProblemAttributes.put("SuperclassInheritedNameHidesEnclosingName", DEPRECATED); > expectedProblemAttributes.put("SuperclassInternalNameProvided", DEPRECATED); >@@ -796,9 +800,6 @@ > expectedProblemAttributes.put("SuperclassNotFound", DEPRECATED); > expectedProblemAttributes.put("SuperclassNotVisible", DEPRECATED); > expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM)); >- expectedProblemAttributes.put("SuperInterfaceMustBeAnInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); >- expectedProblemAttributes.put("SuperInterfacesCollide", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); >- expectedProblemAttributes.put("SuperTypeUsingWildcard", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); > expectedProblemAttributes.put("Task", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); > expectedProblemAttributes.put("ThisInStaticContext", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); > expectedProblemAttributes.put("ThisSuperDuringConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); >@@ -846,7 +847,6 @@ > expectedProblemAttributes.put("UnnecessaryCast", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE)); > expectedProblemAttributes.put("UnnecessaryElse", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE)); > expectedProblemAttributes.put("UnnecessaryInstanceof", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE)); >- expectedProblemAttributes.put("UnnecessaryOperator", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE)); > expectedProblemAttributes.put("UnnecessaryNLSTag", new ProblemAttributes(CategorizedProblem.CAT_NLS)); > expectedProblemAttributes.put("UnqualifiedFieldAccess", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE)); > expectedProblemAttributes.put("UnreachableCatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); >@@ -1079,8 +1079,8 @@ > expectedProblemAttributes.put("DuplicateParameterizedMethods", SKIP); > expectedProblemAttributes.put("DuplicateSuperInterface", SKIP); > expectedProblemAttributes.put("DuplicateTargetInTargetAnnotation", SKIP); >- expectedProblemAttributes.put("DuplicateTypes", SKIP); > expectedProblemAttributes.put("DuplicateTypeVariable", SKIP); >+ expectedProblemAttributes.put("DuplicateTypes", SKIP); > expectedProblemAttributes.put("EmptyControlFlowStatement", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT)); > expectedProblemAttributes.put("EnclosingInstanceInConstructorCall", SKIP); > expectedProblemAttributes.put("EndOfSource", SKIP); >@@ -1109,9 +1109,9 @@ > expectedProblemAttributes.put("FieldTypeNotVisible", SKIP); > expectedProblemAttributes.put("FinalBoundForTypeVariable", new ProblemAttributes(JavaCore.COMPILER_PB_FINAL_PARAMETER_BOUND)); > expectedProblemAttributes.put("FinalFieldAssignment", SKIP); >- expectedProblemAttributes.put("FinallyMustCompleteNormally", new ProblemAttributes(JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING)); > expectedProblemAttributes.put("FinalMethodCannotBeOverridden", SKIP); > expectedProblemAttributes.put("FinalOuterLocalAssignment", SKIP); >+ expectedProblemAttributes.put("FinallyMustCompleteNormally", new ProblemAttributes(JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING)); > expectedProblemAttributes.put("ForbiddenReference", new ProblemAttributes(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE)); > expectedProblemAttributes.put("GenericConstructorTypeArgumentMismatch", SKIP); > expectedProblemAttributes.put("GenericMethodTypeArgumentMismatch", SKIP); >@@ -1215,7 +1215,6 @@ > expectedProblemAttributes.put("InvalidContinue", SKIP); > expectedProblemAttributes.put("InvalidDigit", SKIP); > expectedProblemAttributes.put("InvalidDisjunctiveTypeReferenceSequence", SKIP); >- expectedProblemAttributes.put("InvalidEmptyExoticIdentifier", SKIP); > expectedProblemAttributes.put("InvalidEncoding", SKIP); > expectedProblemAttributes.put("InvalidEscape", SKIP); > expectedProblemAttributes.put("InvalidExplicitConstructorCall", SKIP); >@@ -1241,6 +1240,7 @@ > expectedProblemAttributes.put("InvalidUnicodeEscape", SKIP); > expectedProblemAttributes.put("InvalidUsageOfAnnotationDeclarations", SKIP); > expectedProblemAttributes.put("InvalidUsageOfAnnotations", SKIP); >+ expectedProblemAttributes.put("InvalidUsageOfDiamondConstruct", SKIP); > expectedProblemAttributes.put("InvalidUsageOfEnumDeclarations", SKIP); > expectedProblemAttributes.put("InvalidUsageOfForeachStatements", SKIP); > expectedProblemAttributes.put("InvalidUsageOfStaticImports", SKIP); >@@ -1304,9 +1304,9 @@ > expectedProblemAttributes.put("JavadocNotVisibleField", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("JavadocNotVisibleMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("JavadocNotVisibleType", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); >+ expectedProblemAttributes.put("JavadocParameterMismatch", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("JavadocParameterizedConstructorArgumentTypeMismatch", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("JavadocParameterizedMethodArgumentTypeMismatch", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); >- expectedProblemAttributes.put("JavadocParameterMismatch", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("JavadocTypeArgumentsForRawGenericMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("JavadocUndefinedConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); >@@ -1320,16 +1320,16 @@ > expectedProblemAttributes.put("JavadocUsingDeprecatedField", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("JavadocUsingDeprecatedMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("JavadocUsingDeprecatedType", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); >- expectedProblemAttributes.put("LocalVariableCannotBeNull", SKIP); > expectedProblemAttributes.put("LocalVariableCanOnlyBeNull", SKIP); >+ expectedProblemAttributes.put("LocalVariableCannotBeNull", SKIP); > expectedProblemAttributes.put("LocalVariableHidingField", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING)); > expectedProblemAttributes.put("LocalVariableHidingLocalVariable", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING)); > expectedProblemAttributes.put("LocalVariableIsNeverUsed", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_LOCAL)); > expectedProblemAttributes.put("LocalVariableMayBeNull", SKIP); > expectedProblemAttributes.put("MaskedCatch", new ProblemAttributes(JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK)); > expectedProblemAttributes.put("MethodButWithConstructorName", new ProblemAttributes(JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME)); >- expectedProblemAttributes.put("MethodCanBeStatic", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_STATIC_ON_METHOD)); > expectedProblemAttributes.put("MethodCanBePotentiallyStatic", new ProblemAttributes(JavaCore.COMPILER_PB_POTENTIALLY_MISSING_STATIC_ON_METHOD)); >+ expectedProblemAttributes.put("MethodCanBeStatic", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_STATIC_ON_METHOD)); > expectedProblemAttributes.put("MethodMissingDeprecatedAnnotation", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_DEPRECATED_ANNOTATION)); > expectedProblemAttributes.put("MethodMustOverride", SKIP); > expectedProblemAttributes.put("MethodMustOverrideOrImplement", SKIP); >@@ -1343,7 +1343,7 @@ > expectedProblemAttributes.put("MissingEnclosingInstanceForConstructorCall", SKIP); > expectedProblemAttributes.put("MissingEnumConstantCase", new ProblemAttributes(JavaCore.COMPILER_PB_INCOMPLETE_ENUM_SWITCH)); > expectedProblemAttributes.put("MissingOverrideAnnotation", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION)); >- expectedProblemAttributes.put("MissingOverrideAnnotationForInterfaceMethodImplementation", SKIP); >+ expectedProblemAttributes.put("MissingOverrideAnnotationForInterfaceMethodImplementation", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION)); > expectedProblemAttributes.put("MissingReturnType", SKIP); > expectedProblemAttributes.put("MissingSemiColon", SKIP); > expectedProblemAttributes.put("MissingSerialVersion", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_SERIAL_VERSION)); >@@ -1397,9 +1397,9 @@ > expectedProblemAttributes.put("PackageCollidesWithType", SKIP); > expectedProblemAttributes.put("PackageIsNotExpectedPackage", SKIP); > expectedProblemAttributes.put("ParameterAssignment", new ProblemAttributes(JavaCore.COMPILER_PB_PARAMETER_ASSIGNMENT)); >+ expectedProblemAttributes.put("ParameterMismatch", SKIP); > expectedProblemAttributes.put("ParameterizedConstructorArgumentTypeMismatch", SKIP); > expectedProblemAttributes.put("ParameterizedMethodArgumentTypeMismatch", SKIP); >- expectedProblemAttributes.put("ParameterMismatch", SKIP); > expectedProblemAttributes.put("ParsingError", SKIP); > expectedProblemAttributes.put("ParsingErrorDeleteToken", SKIP); > expectedProblemAttributes.put("ParsingErrorDeleteTokens", SKIP); >@@ -1447,16 +1447,16 @@ > expectedProblemAttributes.put("StaticMemberOfParameterizedType", SKIP); > expectedProblemAttributes.put("StaticMethodRequested", SKIP); > expectedProblemAttributes.put("StringConstantIsExceedingUtf8Limit", SKIP); >- expectedProblemAttributes.put("SuperclassAmbiguous", SKIP); >+ expectedProblemAttributes.put("SuperInterfaceMustBeAnInterface", SKIP); >+ expectedProblemAttributes.put("SuperInterfacesCollide", SKIP); >+ expectedProblemAttributes.put("SuperTypeUsingWildcard", SKIP); >+ expectedProblemAttributes.put("SuperclassAmbiguous", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD)); > expectedProblemAttributes.put("SuperclassInheritedNameHidesEnclosingName", SKIP); > expectedProblemAttributes.put("SuperclassInternalNameProvided", SKIP); > expectedProblemAttributes.put("SuperclassMustBeAClass", SKIP); > expectedProblemAttributes.put("SuperclassNotFound", SKIP); > expectedProblemAttributes.put("SuperclassNotVisible", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_SUPERINTERFACE)); > expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT)); >- expectedProblemAttributes.put("SuperInterfaceMustBeAnInterface", SKIP); >- expectedProblemAttributes.put("SuperInterfacesCollide", SKIP); >- expectedProblemAttributes.put("SuperTypeUsingWildcard", SKIP); > expectedProblemAttributes.put("Task", SKIP); > expectedProblemAttributes.put("ThisInStaticContext", SKIP); > expectedProblemAttributes.put("ThisSuperDuringConstructorInvocation", SKIP); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java,v >retrieving revision 1.5.2.2 >diff -u -r1.5.2.2 GenericsRegressionTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 15 Feb 2011 05:43:49 -0000 1.5.2.2 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 16 Mar 2011 18:44:12 -0000 >@@ -27,7 +27,7 @@ > // Static initializer to specify tests subset using TESTS_* static variables > // All specified tests which does not belong to the class are skipped... > static { >-// TESTS_NAMES = new String[] { "test322531j" }; >+// TESTS_NAMES = new String[] { "test010" }; > // TESTS_NAMES = new String[] { "test1464" }; > // TESTS_NUMBERS = new int[] { 1465 }; > // TESTS_RANGE = new int[] { 1097, -1 }; >@@ -1350,4 +1350,42 @@ > "Cycle detected: the type A cannot extend/implement itself or one of its own member types\n" + > "----------\n"); > } >+public void test339478a() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " public static void main(String[] args) {\n" + >+ " X<String> x = new X<>();\n" + >+ " x.testFunction(\"SUCCESS\");\n" + >+ " }\n" + >+ " public void testFunction(T param){\n" + >+ " System.out.println(param);\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " X<String> x = new X<>();\n" + >+ " ^\n" + >+ "Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>\n" + >+ "----------\n"); >+} >+public void test339478b() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " public static void main(String[] args) {\n" + >+ " X<> x1 = null;\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " X<> x1 = null;\n" + >+ " ^\n" + >+ "Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>\n" + >+ "----------\n"); >+} > } >\ No newline at end of file >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java >=================================================================== >RCS file: src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java >diff -N src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,255 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.tests.compiler.regression; >+ >+import junit.framework.Test; >+public class GenericsRegressionTest_1_7 extends AbstractRegressionTest { >+ >+static { >+// TESTS_NAMES = new String[] { "test004" }; >+// TESTS_NUMBERS = new int[] { 40, 41, 43, 45, 63, 64 }; >+// TESTS_RANGE = new int[] { 11, -1 }; >+} >+public GenericsRegressionTest_1_7(String name) { >+ super(name); >+} >+public static Test suite() { >+ return buildMinimalComplianceTestSuite(testClass(), F_1_7); >+} >+public void test001() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " public static void main(String[] args) {\n" + >+ " X<String> x = new X<>();\n" + >+ " x.testFunction(\"SUCCESS\");\n" + >+ " }\n" + >+ " public void testFunction(T param){\n" + >+ " System.out.println(param);\n" + >+ " }\n" + >+ "}", >+ }, >+ "SUCCESS"); >+} >+public void test002() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " public static void main(String[] args) {\n" + >+ " X x = new X<>();\n" + >+ " x.testFunction(\"SUCCESS\");\n" + >+ " }\n" + >+ " public void testFunction(T param){\n" + >+ " System.out.println(param);\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " X x = new X<>();\n" + >+ " ^\n" + >+ "X is a raw type. References to generic type X<T> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " x.testFunction(\"SUCCESS\");\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method testFunction(Object) belongs to the raw type X. References to generic type X<T> should be parameterized\n" + >+ "----------\n"); >+} >+public void _test003() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " public static void main(String[] args) {\n" + >+ " new X<>().testFunction(\"SUCCESS\");\n" + >+ " }\n" + >+ " public void testFunction(T param){\n" + >+ " System.out.println(param);\n" + >+ " }\n" + >+ "}", >+ }, >+ "SUCCESS"); >+} >+public void test004() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " public static void main(String[] args) {\n" + >+ " new X<>(){\n" + >+ " void newMethod(){\n" + >+ " }\n" + >+ " }.testFunction(\"SUCCESS\");\n" + >+ " }\n" + >+ " public void testFunction(T param){\n" + >+ " System.out.println(param);\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " new X<>(){\n" + >+ " ^\n" + >+ "Empty type argument list cannot be used in anonymous class declaration\n" + >+ "----------\n"); >+} >+public void test005() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " public static void main(String[] args) {\n" + >+ " X Test = new X<>(){\n" + >+ " void newMethod(){\n" + >+ " }\n" + >+ " }.testFunction(\"SUCCESS\");\n" + >+ " }\n" + >+ " public void testFunction(T param){\n" + >+ " System.out.println(param);\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " X Test = new X<>(){\n" + >+ " ^\n" + >+ "X is a raw type. References to generic type X<T> should be parameterized\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " X Test = new X<>(){\n" + >+ " ^\n" + >+ "Empty type argument list cannot be used in anonymous class declaration\n" + >+ "----------\n"); >+} >+public void _test006() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X1<T> {\n" + >+ " int abc = 1;\n" + >+ "}\n" + >+ "public class X<T> extends X1<T> {\n" + >+ " public static void main(String[] args) {\n" + >+ " X1<String> x = new X<>();\n" + >+ " x.testFunction(\"SUCCESS\");\n" + >+ " }\n" + >+ " public void testFunction(T param){\n" + >+ " System.out.println(param);\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " X x = new X<>();\n" + >+ " ^\n" + >+ "X is a raw type. References to generic type X<T> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " x.testFunction(\"SUCCESS\");\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method testFunction(Object) belongs to the raw type X. References to generic type X<T> should be parameterized\n" + >+ "----------\n"); >+} >+// shows the difference between using <> and the raw type - different semantics >+public void _test007() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " T field1;" + >+ " public X(T param){\n" + >+ " field1 = param;\n" + >+ " }\n" + >+ " public static void main(String[] args) {\n" + >+ " X.testFunction(new X<>(\"hello\").getField());\n" + // prints 1 >+ " X.testFunction(new X(\"hello\").getField());\n" + //prints 2 >+ " }\n" + >+ " public static void testFunction(String param){\n" + >+ " System.out.println(1);\n" + >+ " }\n" + >+ " public static void testFunction(Object param){\n" + >+ " System.out.println(2);\n" + >+ " }\n" + >+ " public T getField(){\n" + >+ " return field1;" + >+ " }\n" + >+ "}", >+ }, >+ "1\n" + >+ "2"); >+} >+//shows the difference between using <> and the raw type - different semantics >+public void _test008() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " T field1;" + >+ " public X(T param){\n" + >+ " field1 = param;\n" + >+ " }\n" + >+ " public static void main(String[] args) {\n" + >+ " X<?> x1 = new X(1).get(\"\");\n" + // ok - passing String where Object is expected >+ " X<?> x2 = new X<>(1).get(\"\");\n" + // bad - passing String where Integer is expected >+ " }\n" + >+ " public X<T> get(T t){\n" + >+ " return this;" + >+ " }\n" + >+ "}", >+ }, >+ "1\n" + >+ "2"); >+} >+public void test009() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " public static void main(String[] args) {\n" + >+ " X<>[] x1 = null;\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " X<>[] x1 = null;\n" + >+ " ^\n" + >+ "Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>\n" + >+ "----------\n"); >+} >+public void test010() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " public static void main(String[] args) {\n" + >+ " X<> x1 = null;\n" + // ok - passing String where Object is expected >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " X<> x1 = null;\n" + >+ " ^\n" + >+ "Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>\n" + >+ "----------\n"); >+} >+public static Class testClass() { >+ return GenericsRegressionTest_1_7.class; >+} >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 339478
:
190845
|
191332
|
191458
|
191707
|
191785
|
191891
|
191902
|
191946
|
191947
|
191984
|
192058
|
193887
|
193901
|
193918
|
193951
|
193962
|
193963