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 178149 Details for
Bug 321276
JDT Core APIs don't recognize InnerClass constructor inside .class files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression test
patch_322880.txt (text/plain), 8.29 KB, created by
Olivier Thomann
on 2010-09-03 10:00:11 EDT
(
hide
)
Description:
Proposed fix + regression test
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2010-09-03 10:00:11 EDT
Size:
8.29 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/ClassFileInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java,v >retrieving revision 1.48 >diff -u -r1.48 ClassFileInfo.java >--- model/org/eclipse/jdt/internal/core/ClassFileInfo.java 24 Feb 2010 10:44:11 -0000 1.48 >+++ model/org/eclipse/jdt/internal/core/ClassFileInfo.java 3 Sep 2010 13:59:08 -0000 >@@ -244,12 +244,35 @@ > // TODO (jerome) filter out synthetic members > // indexer should not index them as well > // if ((methodInfo.getModifiers() & IConstants.AccSynthetic) != 0) continue; // skip synthetic >+ boolean useGenericSignature = true; > char[] signature = methodInfo.getGenericSignature(); >- if (signature == null) signature = methodInfo.getMethodDescriptor(); >+ if (signature == null) { >+ useGenericSignature = false; >+ signature = methodInfo.getMethodDescriptor(); >+ } >+ String selector = new String(methodInfo.getSelector()); >+ final boolean isConstructor = methodInfo.isConstructor(); >+ if (isConstructor) { >+ selector = type.getElementName(); >+ } > String[] pNames = null; > try { > pNames = Signature.getParameterTypes(new String(signature)); >- } catch (IllegalArgumentException e) { >+ if (isConstructor >+ && useGenericSignature >+ && type.isMember() >+ && !Flags.isStatic(type.getFlags())) { >+ int length = pNames.length; >+ System.arraycopy(pNames, 0, (pNames = new String[length + 1]), 1, length); >+ char[] descriptor = methodInfo.getMethodDescriptor(); >+ final String[] parameterTypes = Signature.getParameterTypes(new String(descriptor)); >+ pNames[0] = parameterTypes[0]; >+ } >+ }catch (IllegalArgumentException e) { >+ // protect against malformed .class file (e.g. com/sun/crypto/provider/SunJCE_b.class has a 'a' generic signature) >+ signature = methodInfo.getMethodDescriptor(); >+ pNames = Signature.getParameterTypes(new String(signature)); >+ } catch (JavaModelException e) { > // protect against malformed .class file (e.g. com/sun/crypto/provider/SunJCE_b.class has a 'a' generic signature) > signature = methodInfo.getMethodDescriptor(); > pNames = Signature.getParameterTypes(new String(signature)); >@@ -260,10 +283,6 @@ > } > char[][] parameterTypes = ClassFile.translatedNames(paramNames); > JavaModelManager manager = JavaModelManager.getJavaModelManager(); >- String selector = new String(methodInfo.getSelector()); >- if (methodInfo.isConstructor()) { >- selector =type.getElementName(); >- } > selector = manager.intern(selector); > for (int j= 0; j < pNames.length; j++) { > pNames[j]= manager.intern(new String(parameterTypes[j])); >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java,v >retrieving revision 1.65 >diff -u -r1.65 AttachSourceTests.java >--- src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java 10 Dec 2009 16:00:07 -0000 1.65 >+++ src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java 3 Sep 2010 13:59:09 -0000 >@@ -36,7 +36,7 @@ > */ > public class AttachSourceTests extends ModifyingResourceTests { > static { >-// TESTS_NAMES = new String[] { "testClassFileBuffer" }; >+// TESTS_NAMES = new String[] { "testConstructorAccess" }; > // TESTS_NUMBERS = new int[] { 5 }; > // TESTS_RANGE = new int[] { 169, 180 }; > } >@@ -127,6 +127,14 @@ > " }\n" + > "}\n" + > "class AType<E> {\n" + // type name containing character 'T' >+ "}", >+ "Container.java", >+ "public class Container {\n" + >+ " class Inner<S> {\n" + >+ " Inner(String st, Class<S> s) {\n" + >+ " super();\n" + >+ " }\n" + >+ " }\n" + > "}" > }; > addLibrary("generic.jar", "genericsrc.zip", pathAndContents, JavaCore.VERSION_1_5); >@@ -951,7 +959,7 @@ > } > > /* >- * Ensures that having a project as source attachement finds the source >+ * Ensures that having a project as source attachment finds the source > * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=65186) > */ > public void testProjectAsSourceAttachment() throws CoreException { >@@ -1062,7 +1070,7 @@ > root.close(); > } > /** >- * Attach a jar with a source attachement that doesn't contain the source folders >+ * Attach a jar with a source attachment that doesn't contain the source folders > */ > public void testRootPath4() throws JavaModelException { > IJavaProject project = getJavaProject("/AttachSourceTests"); >@@ -1079,7 +1087,7 @@ > root.close(); > } > /** >- * Attach a jar with a source attachement that doesn't contain the source folders >+ * Attach a jar with a source attachment that doesn't contain the source folders > */ > public void testRootPath5() throws JavaModelException { > IJavaProject project = getJavaProject("/AttachSourceTests"); >@@ -1104,7 +1112,7 @@ > root.close(); > } > /** >- * Attach a jar with a source attachement that doesn't contain the source folders >+ * Attach a jar with a source attachment that doesn't contain the source folders > */ > public void testRootPath6() throws JavaModelException { > IJavaProject project = getJavaProject("/AttachSourceTests"); >@@ -1129,7 +1137,7 @@ > root.close(); > } > /** >- * Attach a jar with a source attachement that doesn't contain the source folders >+ * Attach a jar with a source attachment that doesn't contain the source folders > */ > public void testRootPath7() throws JavaModelException { > IJavaProject project = getJavaProject("/AttachSourceTests"); >@@ -1162,7 +1170,7 @@ > root.close(); > } > /** >- * Attach a jar with a source attachement that contains the source folders >+ * Attach a jar with a source attachment that contains the source folders > */ > public void testRootPath8() throws JavaModelException { > IJavaProject project = getJavaProject("/AttachSourceTests"); >@@ -1195,7 +1203,7 @@ > root.close(); > } > /** >- * Attach a jar with a source attachement that contains the source folders >+ * Attach a jar with a source attachment that contains the source folders > */ > public void testRootPath9() throws JavaModelException { > IJavaProject project = getJavaProject("/AttachSourceTests"); >@@ -1228,7 +1236,7 @@ > root.close(); > } > /** >- * Attach a jar with a source attachement that is itself >+ * Attach a jar with a source attachment that is itself > */ > public void testRootPath10() throws JavaModelException { > IJavaProject project = getJavaProject("/AttachSourceTests"); >@@ -1279,8 +1287,8 @@ > root.close(); > } > /** >- * Attach a jar with a source attachement that is itself. The jar contains 2 root paths for the same class file. >- * (regression test for bug 74014 prefix path for source attachements - automatic detection does not seem to work) >+ * Attach a jar with a source attachment that is itself. The jar contains 2 root paths for the same class file. >+ * (regression test for bug 74014 prefix path for source attachments - automatic detection does not seem to work) > */ > public void testRootPath12() throws JavaModelException { > IJavaProject project = getJavaProject("/AttachSourceTests"); >@@ -1514,4 +1522,26 @@ > IBuffer buffer2 = classFile.getBuffer(); > assertTrue("Same buffer is not reused", buffer2 == buffer); > } >+/** >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=242029 >+ */ >+public void testConstructorAccess() throws JavaModelException { >+ IJavaProject project = this.getJavaProject("/AttachSourceTests"); >+ IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/AttachSourceTests/generic.jar")); >+ attachSource(root, "/AttachSourceTests/genericsrc.zip", null); >+ >+ IClassFile cf = root.getPackageFragment("").getClassFile("Container$Inner.class"); >+ final IType type = cf.getType(); >+ final IMethod[] methods = type.getMethods(); >+ assertEquals("wrong size", 1, methods.length); >+ assertTrue("Not a constructor", methods[0].isConstructor()); >+ assertSourceEquals( >+ "Unexpected source for generic constructor", >+ "Inner(String st, Class<S> s) {\n" + >+ " super();\n" + >+ " }", >+ methods[0].getSource()); >+ attachSource(root, null, null); // detach source >+ root.close(); >+} > }
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 321276
:
178060
| 178149