Merge branch 'cannot-resolve-ambiguous-dollar' into 7.0.x

Old cleanups
This commit is contained in:
Clément Fournier
2022-03-15 22:56:02 +01:00
4 changed files with 1 additions and 40 deletions

View File

@ -83,28 +83,6 @@ public class AsmSymbolResolver implements SymbolResolver {
return binaryName.replace('.', '/');
}
/**
* Test whether an internal name has a canonical name. This means,
* every segment of the simple name (part after the last '/'), where
* segments are separated by '$', is a valid java identifier. We only
* check the first character as anon/local classes are identified with
* integers, which are not valid java identifier starts.
*/
static boolean hasCanonicalName(String internalName) {
int packageEnd = internalName.lastIndexOf('/');
for (int i = packageEnd; i + 1 < internalName.length();) {
char firstChar = internalName.charAt(i + 1);
if (!Character.isJavaIdentifierStart(firstChar)) {
return false;
}
i = internalName.indexOf('$', i + 1);
if (i == -1) {
break;
}
}
return !internalName.isEmpty();
}
@Nullable
URL getUrlOfInternalName(String internalName) {
return classLoader.findResource(internalName + ".class");

View File

@ -44,7 +44,6 @@ final class ClassStub implements JClassSymbol, AsmStub {
static final int UNKNOWN_ARITY = 0;
private final AsmSymbolResolver resolver;
private final Loader loader;
private final Names names;
@ -76,7 +75,6 @@ final class ClassStub implements JClassSymbol, AsmStub {
this.resolver = resolver;
this.names = new Names(internalName);
this.loader = loader;
this.parseLock = new ParseLock() {
// note to devs: to debug the parsing logic you might have
@ -132,10 +130,6 @@ final class ClassStub implements JClassSymbol, AsmStub {
};
}
Loader getLoader() {
return loader;
}
@Override
public AsmSymbolResolver getResolver() {
return resolver;

View File

@ -1147,7 +1147,7 @@ public final class TypeOps {
// <editor-fold defaultstate="collapsed" desc="Overriding">
/**
* Returns true if m1 is return-type substitutable with m2. . The notion of return-type-substitutability
* Returns true if m1 is return-type substitutable with m2. The notion of return-type-substitutability
* supports covariant returns, that is, the specialization of the return type to a subtype.
*
* https://docs.oracle.com/javase/specs/jls/se9/html/jls-8.html#jls-8.4.5

View File

@ -30,17 +30,6 @@ class NamesTest : IntelliMarker, FunSpec({
names.packageName shouldBe ""
}
test("Test cano name") {
AsmSymbolResolver.hasCanonicalName("Num") shouldBe true
AsmSymbolResolver.hasCanonicalName("") shouldBe false
AsmSymbolResolver.hasCanonicalName("a/b/C") shouldBe true
AsmSymbolResolver.hasCanonicalName("a/b/C\$D") shouldBe true
AsmSymbolResolver.hasCanonicalName("a/b/C\$1D") shouldBe false
AsmSymbolResolver.hasCanonicalName("a/b/C\$1D\$D") shouldBe false
AsmSymbolResolver.hasCanonicalName("a/b/C\$D\$1") shouldBe false
AsmSymbolResolver.hasCanonicalName("a/b/C\$D") shouldBe true
}
test("Test names with trailing dollar") {
val names = ClassStub.Names("javasymbols/testdata/deep/ClassWithDollar\$")