diff options
author | Till Brychcy | 2019-08-06 21:14:48 +0000 |
---|---|---|
committer | Till Brychcy | 2019-08-08 11:03:58 +0000 |
commit | 181d12a804961d5320f326f8d24d7575ae4b84ac (patch) | |
tree | 11786a6f1cdb99c9112f140349daf5958caaec4f | |
parent | b17fbd578b6634c1fe3eb3af977364d72958da78 (diff) | |
download | eclipse.jdt.core-181d12a804961d5320f326f8d24d7575ae4b84ac.tar.gz eclipse.jdt.core-181d12a804961d5320f326f8d24d7575ae4b84ac.tar.xz eclipse.jdt.core-181d12a804961d5320f326f8d24d7575ae4b84ac.zip |
Bug 548596 - Eclipse compiler don't see Kotlin generated classes deeper
than one level
Change-Id: I7a110c37c26c0584f1eb26da125692e5ea9240d3
3 files changed, 43 insertions, 10 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_8.java index 9bfdf85edd..f63069d470 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_8.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_8.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2016 GoPivotal, Inc. + * Copyright (c) 2013, 2019 GoPivotal, Inc. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -16,6 +16,8 @@ package org.eclipse.jdt.core.tests.compiler.regression; import junit.framework.Test; +import java.io.File; + import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; @@ -432,6 +434,41 @@ public class ClassFileReaderTest_1_8 extends AbstractRegressionTest { assertEquals(((org.eclipse.jdt.internal.compiler.impl.Constant)method.getDefaultValue()).stringValue(), "aaa"); } + public void testBug548596() { + /*- + * Test548596.jar contains classes for the following kotlin code (compiled with kotlin 1.3.21): + * package k; + * class A { + * class B { + * class C { + * // + * } + * } + * } + */ + String[] libs = getDefaultClassPaths(); + int len = libs.length; + System.arraycopy(libs, 0, libs = new String[len+1], 0, len); + libs[libs.length-1] = this.getCompilerTestsPluginDirectoryPath() + File.separator + "workspace" + File.separator + "Test548596.jar"; + + runConformTest( + new String[] { + "j/Usage.java", + "package j;\n" + + "\n" + + "import k.A.B.C;\n" + + "\n" + + "public class Usage {\n" + + " C c;\n" + + "}" + }, + "", + libs, + false, + null + ); + } + /** * Produce a nicely formatted type annotation for testing. Exercises the API for type annotations. * Output examples:<br> diff --git a/org.eclipse.jdt.core.tests.compiler/workspace/Test548596.jar b/org.eclipse.jdt.core.tests.compiler/workspace/Test548596.jar Binary files differnew file mode 100644 index 0000000000..e51ef396dc --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/workspace/Test548596.jar diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java index 64902f4a4f..a8f8ab7eaa 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -62,7 +62,6 @@ public class ClassFileReader extends ClassFileStruct implements IBinaryType { // initialized in case the .class file is a nested type private InnerClassInfo innerInfo; - private int innerInfoIndex; private InnerClassInfo[] innerInfos; private char[][] interfaceNames; private int interfacesCount; @@ -373,7 +372,6 @@ public ClassFileReader(byte[] classFileBytes, char[] fileName, boolean fullyInit new InnerClassInfo(this.reference, this.constantPoolOffsets, innerOffset); if (this.classNameIndex == this.innerInfos[j].innerClassNameIndex) { this.innerInfo = this.innerInfos[j]; - this.innerInfoIndex = j; } innerOffset += 8; } @@ -711,14 +709,12 @@ public IBinaryNestedType[] getMemberTypes() { // we might have some member types of the current type if (this.innerInfos == null) return null; - int length = this.innerInfos.length; - int startingIndex = this.innerInfo != null ? this.innerInfoIndex + 1 : 0; - if (length != startingIndex) { + int length = this.innerInfos.length - (this.innerInfo != null ? 1 : 0); + if (length != 0) { IBinaryNestedType[] memberTypes = - new IBinaryNestedType[length - this.innerInfoIndex]; + new IBinaryNestedType[length]; int memberTypeIndex = 0; - for (int i = startingIndex; i < length; i++) { - InnerClassInfo currentInnerInfo = this.innerInfos[i]; + for (InnerClassInfo currentInnerInfo : this.innerInfos) { int outerClassNameIdx = currentInnerInfo.outerClassNameIndex; int innerNameIndex = currentInnerInfo.innerNameIndex; /* |