diff options
author | Stephan Herrmann | 2020-01-15 22:12:07 +0000 |
---|---|---|
committer | Stephan Herrmann | 2020-01-15 22:12:07 +0000 |
commit | 9eac2d764cbec2160db1c91a3a05341846688165 (patch) | |
tree | 84d9d46a416375b51e78f3d3c50bc61002e69eb6 | |
parent | d5bebfcd41e40e691236ae672f0c877a727409c1 (diff) | |
download | eclipse.jdt.core-9eac2d764cbec2160db1c91a3a05341846688165.tar.gz eclipse.jdt.core-9eac2d764cbec2160db1c91a3a05341846688165.tar.xz eclipse.jdt.core-9eac2d764cbec2160db1c91a3a05341846688165.zip |
Bug 559210 - NullPointerExeption atI20200116-1800I20200116-0930I20200116-0330I20200116-0310I20200115-1800
SourceTypeBinding.hasMethodWithNumArgs
Change-Id: I7f69654dbd633a6559dab38019b99ad5684e5a0e
2 files changed, 59 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java index 4a8587c514..b12283be76 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java @@ -3262,4 +3262,62 @@ public void testBug425111() throws Exception { if (javaProject1 != null) deleteProject(javaProject1); } } +public void testBug559210() throws CoreException { + try { + createJavaProject("P", new String[] {"src"}, new String[] {"JCL_LIB", "lib"}, "bin", "1.7"); + createFolder("/P/src/java/io"); + createFile( + "/P/src/java/io/Closeable.java", + "pakage java.io;\n" + + "public interface Closeable { void close(); }\n"); + createFile( + "/P/src/java/io/InputStream.java", + "pakage java.io;\n" + + "public abstract class InputStream implements Closeable { }\n"); + + createFolder("/P/src/p"); + createFile( + "/P/src/p/ReferenceInputStream.java", + "pakage p;\n" + + "public class ReferenceInputStream extends java.io.InputStream {\n" + + " private final File reference;\n" + + "\n" + + " public ReferenceInputStream(File reference) {\n" + + " this.reference = reference;\n" + + " }\n" + + "\n" + + " /* This method should not be called.\n" + + " */\n" + + " @Override\n" + + " public int read() throws IOException {\n" + + " throw new IOException();\n" + + " }\n" + + "\n" + + " public File getReference() {\n" + + " return reference;\n" + + " }\n" + + "}" + ); + createFile( + "/P/src/p/Storage.java", + "pakage p;\n" + + "import p.ReferenceInputStream;\n" + + "public class Storage {\n" + + "\n" + + " public ReferenceInputStream stream;\n" + + "}" + ); + getProject("P").build(IncrementalProjectBuilder.FULL_BUILD, null); + waitForAutoBuild(); + ITypeHierarchy hierarchy = getCompilationUnit("/P/src/p/Storage.java").getTypes()[0].newSupertypeHierarchy(null); + assertHierarchyEquals( + "Focus: Storage [in Storage.java [in p [in src [in P]]]]\n" + + "Super types:\n" + + " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" + + "Sub types:\n", + hierarchy); + } finally { + deleteProject("P"); + } +} } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java index a8f9b01261..1346665326 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java @@ -2272,7 +2272,7 @@ protected boolean hasMethodWithNumArgs(char[] selector, int numArgs) { if ((this.tagBits & TagBits.AreMethodsComplete) != 0) return super.hasMethodWithNumArgs(selector, numArgs); // otherwise don't trigger unResolvedMethods() which would actually resolve! - if (this.scope != null) { + if (this.scope != null && this.scope.referenceContext.methods != null) { for (AbstractMethodDeclaration method : this.scope.referenceContext.methods) { if (CharOperation.equals(method.selector, TypeConstants.CLOSE)) { if (numArgs == 0) { |