Skip to content

Commit

Permalink
JDT Core throws NullPointerException: Cannot read the array length
Browse files Browse the repository at this point in the history
because "argumentBindings" is null

fixes eclipse-jdt#2386 and eclipse-jdt#2399
  • Loading branch information
stephan-herrmann committed May 2, 2024
1 parent 1a83577 commit d7ac21c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,9 @@ public void updateSupertypesWithAnnotations(Map<ReferenceBinding,ReferenceBindin
if (this.binding instanceof MemberTypeBinding) {
((MemberTypeBinding) this.binding).updateDeprecationFromEnclosing();
}
Map<ReferenceBinding,ReferenceBinding> updates = new HashMap<>();
if (this.binding.isHierarchyInconsistent())
return;
Map<ReferenceBinding,ReferenceBinding> updates = new HashMap<>();
if (this.typeParameters != null) {
for (TypeParameter typeParameter : this.typeParameters) {
typeParameter.updateWithAnnotations(this.scope); // TODO: need to integrate with outerUpdates/updates?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10817,4 +10817,51 @@ public <R> MyGeneric<R> lambda(java.util.function.Function<String, MyGeneric<R>>
"""
});
}

public void testGH2386() {
Runner runner = new Runner();
runner.testFiles = new String[] {
"TestClass.java",
"""
public class TestClass<E> {
class Itr { }
class C123172 extends TestClass.Itr<Missing<E>> { }
}
"""
};
runner.expectedCompilerLog = """
----------
1. ERROR in TestClass.java (at line 3)
class C123172 extends TestClass.Itr<Missing<E>> { }
^^^^^^^^^^^^^
The type TestClass.Itr is not generic; it cannot be parameterized with arguments <Missing<E>>
----------
2. ERROR in TestClass.java (at line 3)
class C123172 extends TestClass.Itr<Missing<E>> { }
^^^^^^^
Missing cannot be resolved to a type
----------
""";
runner.runNegativeTest();
}

public void testGH2399() {
Runner runner = new Runner();
runner.testFiles = new String[] {
"TestClass.java",
"""
public class TestClass implements TestClass.Missing1<TestClass.Missing2<TestClass.Missing3>> {
}
"""
};
runner.expectedCompilerLog = """
----------
1. ERROR in TestClass.java (at line 1)
public class TestClass implements TestClass.Missing1<TestClass.Missing2<TestClass.Missing3>> {
^^^^^^^^^^^^^^^^^^
Cycle detected: the type TestClass cannot extend/implement itself or one of its own member types
----------
""";
runner.runNegativeTest();
}
}

0 comments on commit d7ac21c

Please sign in to comment.