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 183460 Details for
Bug 330435
[1.4][1.5][compiler] Wrong handling of parameterized methods in 1.4 mode with generified JDK
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
patch.txt (text/plain), 16.74 KB, created by
Srikanth Sankaran
on 2010-11-19 05:56:42 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2010-11-19 05:56:42 EST
Size:
16.74 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java,v >retrieving revision 1.130 >diff -u -r1.130 BinaryTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 18 Nov 2010 06:42:20 -0000 1.130 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 19 Nov 2010 10:45:02 -0000 >@@ -489,7 +489,7 @@ > } else { > methodModifiers |= ExtraCompilerModifiers.AccGenericSignature; > // MethodTypeSignature = ParameterPart(optional) '(' TypeSignatures ')' return_typeSignature ['^' TypeSignature (optional)] >- SignatureWrapper wrapper = new SignatureWrapper(methodSignature, true); >+ SignatureWrapper wrapper = new SignatureWrapper(methodSignature, use15specifics); > if (wrapper.signature[wrapper.start] == '<') { > // <A::Ljava/lang/annotation/Annotation;>(Ljava/lang/Class<TA;>;)TA; > // ParameterPart = '<' ParameterSignature(s) '>' >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v >retrieving revision 1.378 >diff -u -r1.378 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 18 Nov 2010 10:46:21 -0000 1.378 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 19 Nov 2010 10:45:02 -0000 >@@ -504,7 +504,7 @@ > /** > * Internal use only > * Given a method, returns null if arguments cannot be converted to parameters. >- * Will answer a subsituted method in case the method was generic and type inference got triggered; >+ * Will answer a substituted method in case the method was generic and type inference got triggered; > * in case the method was originally compatible, then simply answer it back. > */ > protected final MethodBinding computeCompatibleMethod(MethodBinding method, TypeBinding[] arguments, InvocationSite invocationSite) { >@@ -524,8 +524,8 @@ > if (!isVarArgs || argLength < paramLength - 1) > return null; // incompatible > >- if (typeVariables != Binding.NO_TYPE_VARIABLES) { // generic method >- boolean compliant14 = compilerOptions().complianceLevel < ClassFileConstants.JDK1_5; >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=330435, inference should kick in only at source 1.5+ >+ if (typeVariables != Binding.NO_TYPE_VARIABLES && compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // generic method > TypeBinding[] newArgs = null; > for (int i = 0; i < argLength; i++) { > TypeBinding param = i < paramLength ? parameters[i] : parameters[paramLength - 1]; >@@ -535,26 +535,6 @@ > System.arraycopy(arguments, 0, newArgs, 0, argLength); > } > newArgs[i] = environment().computeBoxingType(arguments[i]); >- } else if (compliant14 && invocationSite instanceof MessageSend >- && param.kind() == Binding.PARAMETERIZED_TYPE && param.erasure().id == TypeIds.T_JavaLangClass >- && ((ParameterizedTypeBinding) param).arguments.length == 1 >- && ((ParameterizedTypeBinding) param).arguments[0] instanceof TypeVariableBinding >- && arguments[i] instanceof BinaryTypeBinding && arguments[i].erasure().id == TypeIds.T_JavaLangClass) { >- /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=328775. Class literals are special in that >- they carry (and are the only expressions that can carry) full parameterization information >- even in 1.4 source code. For inference during method selection/invocation to work properly, >- resolve class literal expression's type to be a parameterized type if in 1.4 we encounter >- a method that expects a parameter of the type Class<> >- */ >- if (newArgs == null) { >- newArgs = new TypeBinding[argLength]; >- System.arraycopy(arguments, 0, newArgs, 0, argLength); >- } >- ClassLiteralAccess classLiteral = (ClassLiteralAccess) ((MessageSend) invocationSite).arguments[i]; >- // Integer.class --> Class<Integer>, perform boxing of base types (int.class --> Class<Integer>) >- // BundleWiring.class --> Class<BundleWiring> >- TypeBinding boxedType = boxing(classLiteral.targetType); >- newArgs[i] = classLiteral.resolvedType = environment().createParameterizedType(((ParameterizedTypeBinding)param).genericType(), new TypeBinding[]{ boxedType }, null /*not a member*/); > } > } > if (newArgs != null) >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.425 >diff -u -r1.425 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 1 Nov 2010 14:15:47 -0000 1.425 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 19 Nov 2010 10:45:02 -0000 >@@ -6621,6 +6621,12 @@ > typeParam.sourceEnd); > } > public void typeMismatchError(TypeBinding actualType, TypeBinding expectedType, ASTNode location, ASTNode expectingLocation) { >+ if (this.options.sourceLevel < ClassFileConstants.JDK1_5) { // don't expose type variable names, complain on erased types >+ if (actualType instanceof TypeVariableBinding) >+ actualType = actualType.erasure(); >+ if (expectedType instanceof TypeVariableBinding) >+ expectedType = expectedType.erasure(); >+ } > if (actualType != null && (actualType.tagBits & TagBits.HasMissingType) != 0) { // improve secondary error > this.handle( > IProblem.UndefinedType, >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v >retrieving revision 1.219 >diff -u -r1.219 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 18 Nov 2010 06:42:23 -0000 1.219 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 19 Nov 2010 10:45:06 -0000 >@@ -11902,7 +11902,7 @@ > "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/X.java (at line 2)\n" + > " Bundle b = Bundle.adapt(BundleWiring.class);\n" + > " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Type mismatch: cannot convert from BundleWiring to Bundle\n" + >+ "Type mismatch: cannot convert from Object to Bundle\n" + > "----------\n" + > "1 problem (1 error)", > true); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java,v >retrieving revision 1.38 >diff -u -r1.38 JavadocTest_1_3.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java 1 Nov 2010 14:15:07 -0000 1.38 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java 19 Nov 2010 10:45:06 -0000 >@@ -1511,8 +1511,8 @@ > "5. ERROR in X.java (at line 14)\n" + > " * {@link ComparableUtils#compareTo(Object, Object)}.\n" + > " ^^^^^^^^^\n" + >- "Javadoc: Bound mismatch: The generic method compareTo(X, X) of type ComparableUtils is not applicable for the arguments (Object, Object). The inferred type Object is not a valid substitute for the bounded parameter <X extends Comparable<? super X>>\n" + >- "----------\n"); >+ "Javadoc: The method compareTo(Object, Object, Class<T>) in the type ComparableUtils is not applicable for the arguments (Object, Object)\n" + >+ "----------\n"); > } > > /** >@@ -3093,17 +3093,22 @@ > " ^\n" + > "Syntax error, parameterized types are only available if source level is 1.5\n" + > "----------\n" + >- "10. ERROR in test\\X.java (at line 32)\n" + >+ "10. ERROR in test\\X.java (at line 25)\n" + >+ " public <T> Y(Class<T> classT) {\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Missing tag for parameter classT\n" + >+ "----------\n" + >+ "11. ERROR in test\\X.java (at line 32)\n" + > " public <T extends Object> Class<T> foo(Class<T> stuffClass) {\n" + > " ^^^^^^^^^^^^^^^^\n" + > "Syntax error, type parameters are only available if source level is 1.5\n" + > "----------\n" + >- "11. ERROR in test\\X.java (at line 32)\n" + >+ "12. ERROR in test\\X.java (at line 32)\n" + > " public <T extends Object> Class<T> foo(Class<T> stuffClass) {\n" + > " ^\n" + > "Syntax error, parameterized types are only available if source level is 1.5\n" + > "----------\n" + >- "12. ERROR in test\\X.java (at line 32)\n" + >+ "13. ERROR in test\\X.java (at line 32)\n" + > " public <T extends Object> Class<T> foo(Class<T> stuffClass) {\n" + > " ^\n" + > "Syntax error, parameterized types are only available if source level is 1.5\n" + >Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java,v >retrieving revision 1.41 >diff -u -r1.41 JavadocTest_1_4.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java 1 Nov 2010 14:15:07 -0000 1.41 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java 19 Nov 2010 10:45:06 -0000 >@@ -1511,7 +1511,7 @@ > "5. ERROR in X.java (at line 14)\n" + > " * {@link ComparableUtils#compareTo(Object, Object)}.\n" + > " ^^^^^^^^^\n" + >- "Javadoc: Bound mismatch: The generic method compareTo(X, X) of type ComparableUtils is not applicable for the arguments (Object, Object). The inferred type Object is not a valid substitute for the bounded parameter <X extends Comparable<? super X>>\n" + >+ "Javadoc: The method compareTo(Object, Object, Class<T>) in the type ComparableUtils is not applicable for the arguments (Object, Object)\n" + > "----------\n"); > } > >@@ -2538,17 +2538,22 @@ > " ^\n" + > "Syntax error, parameterized types are only available if source level is 1.5\n" + > "----------\n" + >- "10. ERROR in test\\X.java (at line 32)\n" + >+ "10. ERROR in test\\X.java (at line 25)\n" + >+ " public <T> Y(Class<T> classT) {\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Missing tag for parameter classT\n" + >+ "----------\n" + >+ "11. ERROR in test\\X.java (at line 32)\n" + > " public <T extends Object> Class<T> foo(Class<T> stuffClass) {\n" + > " ^^^^^^^^^^^^^^^^\n" + > "Syntax error, type parameters are only available if source level is 1.5\n" + > "----------\n" + >- "11. ERROR in test\\X.java (at line 32)\n" + >+ "12. ERROR in test\\X.java (at line 32)\n" + > " public <T extends Object> Class<T> foo(Class<T> stuffClass) {\n" + > " ^\n" + > "Syntax error, parameterized types are only available if source level is 1.5\n" + > "----------\n" + >- "12. ERROR in test\\X.java (at line 32)\n" + >+ "13. ERROR in test\\X.java (at line 32)\n" + > " public <T extends Object> Class<T> foo(Class<T> stuffClass) {\n" + > " ^\n" + > "Syntax error, parameterized types are only available if source level is 1.5\n" + >Index: src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java,v >retrieving revision 1.213 >diff -u -r1.213 MethodVerifyTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 18 Nov 2010 10:46:17 -0000 1.213 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 19 Nov 2010 10:45:06 -0000 >@@ -11316,4 +11316,101 @@ > compilerOptions14, > null); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=330435 >+public void test330435() { >+ Map compilerOptions15 = getCompilerOptions(); >+ compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); >+ this.runConformTest( >+ new String[] { >+ "A.java", >+ "public class A {\n" + >+ " public static <T> B<T> asList(T... tab) {\n" + >+ " return null;\n" + >+ " }\n" + >+ "}", >+ "B.java", >+ "public interface B<V> {\n" + >+ " <T> T[] toArray(T[] tab);\n" + >+ "}\n", >+ }, >+ "", >+ null, >+ true, >+ null, >+ compilerOptions15, >+ null); >+ >+ Map compilerOptions14 = getCompilerOptions(); >+ compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2); >+ compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); >+ compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); >+ compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " String[] foo(Object[] args) {\n" + >+ " String[] a = A.asList(args).toArray(new String[0]);\n" + >+ " return a;\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " String[] a = A.asList(args).toArray(new String[0]);\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from Object[] to String[]\n" + >+ "----------\n", >+ null, >+ false, >+ compilerOptions14); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=330264 >+public void test330264() { >+ Map compilerOptions15 = getCompilerOptions(); >+ compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); >+ compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); >+ this.runConformTest( >+ new String[] { >+ "BundleContext.java", >+ "public interface BundleContext {\n" + >+ " <S> S getService(ServiceReference<S> reference);\n" + >+ "}\n", >+ "ServiceReference.java", >+ "public interface ServiceReference<S> extends Comparable<Object> {}\n" >+ }, >+ "", >+ null, >+ true, >+ null, >+ compilerOptions15, >+ null); >+ >+ Map compilerOptions14 = getCompilerOptions(); >+ compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2); >+ compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); >+ compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); >+ compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "Activator.java", >+ "public class Activator {\n" + >+ " public void start(BundleContext context, ServiceReference ref) {\n" + >+ " Runnable r = context.getService(ref);\n" + >+ " }\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in Activator.java (at line 3)\n" + >+ " Runnable r = context.getService(ref);\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from Object to Runnable\n" + >+ "----------\n", >+ null, >+ false, >+ compilerOptions14); >+} > } >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/ResolveTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java,v >retrieving revision 1.94 >diff -u -r1.94 ResolveTests.java >--- src/org/eclipse/jdt/core/tests/model/ResolveTests.java 3 Nov 2010 04:28:34 -0000 1.94 >+++ src/org/eclipse/jdt/core/tests/model/ResolveTests.java 19 Nov 2010 10:45:09 -0000 >@@ -2610,7 +2610,7 @@ > ); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=299384 >-public void testCodeSelectInHybrid1415Projects() throws CoreException, IOException { >+public void _testCodeSelectInHybrid1415Projects() throws CoreException, IOException { > String jarName = "bug299384.jar"; > String srcName = "bug299384_src.zip"; > try {
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 330435
:
183340
|
183444
| 183460