diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SignatureTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SignatureTests.java index 9bbca0bb96e..01934f25bfd 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SignatureTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SignatureTests.java @@ -1598,6 +1598,15 @@ public void testCreateIntersectionTypeSignature2() { Signature.getIntersectionTypeBounds(signature) ); } + +public void testDollarPackage() { + String signature = Signature.getTypeErasure("Ljava.util.$foo$.Optional"); + assertEquals( + "Ljava.util.$foo$.Optional", + new String(signature.toCharArray()) + ); +} + // Bug 380048 - error popup when navigating to source files public void testSourceMapperSigConversion01() { SourceMapper mapper = new SourceMapper(); diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java index 654e8e7de8f..64e82e24b50 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java @@ -638,6 +638,8 @@ private static int appendClassTypeSignature(char[] string, int start, boolean fu throw newIllegalArgumentException(string, start); } c = string[p]; + char prevC = string[p - 1]; + char nextC = p < string.length - 1 ? string[p + 1] : 0; switch(c) { case C_SEMICOLON : // all done @@ -668,15 +670,19 @@ private static int appendClassTypeSignature(char[] string, int start, boolean fu innerTypeStart = buffer.length(); inAnonymousType = false; if (resolved) { - // once we hit "$" there are no more package prefixes - removePackageQualifiers = false; - /** - * Convert '$' in resolved type signatures into '.'. - * NOTE: This assumes that the type signature is an inner type - * signature. This is true in most cases, but someone can define a - * non-inner type name containing a '$'. - */ - buffer.append('.'); + if (prevC == C_DOT || nextC == C_DOT) { + buffer.append('$'); + } else { + // once we hit "$" there are no more package prefixes + removePackageQualifiers = false; + /** + * Convert '$' in resolved type signatures into '.'. + * NOTE: This assumes that the type signature is an inner type + * signature. This is true in most cases, but someone can define a + * non-inner type name containing a '$'. + */ + buffer.append('.'); + } } break; default :