diff options
author | Yohann Roussel <yroussel@google.com> | 2014-09-04 14:53:33 +0200 |
---|---|---|
committer | Yohann Roussel <yroussel@google.com> | 2014-09-09 15:28:34 +0200 |
commit | 79a71d1cf80a1eb934aa03b018b4664eeced9fa4 (patch) | |
tree | 3c725b67349913df24b9937ee070ad03b2981932 | |
parent | 5caac3900b193b8313ad32cf11bc38f0f3ba97f7 (diff) | |
download | toolchain_jack-79a71d1cf80a1eb934aa03b018b4664eeced9fa4.zip toolchain_jack-79a71d1cf80a1eb934aa03b018b4664eeced9fa4.tar.gz toolchain_jack-79a71d1cf80a1eb934aa03b018b4664eeced9fa4.tar.bz2 |
Do not crash when inner class is missing in classpath.
Just do just as if the missing classes had never existed.
Bug: 17384804
Change-Id: I44038c0d9294bd64788e4fa9fa11a5809d4b8e29
3 files changed, 22 insertions, 16 deletions
diff --git a/jack/src/com/android/jack/ecj/loader/jast/JAstBinaryType.java b/jack/src/com/android/jack/ecj/loader/jast/JAstBinaryType.java index e8a06ba..d71297d 100644 --- a/jack/src/com/android/jack/ecj/loader/jast/JAstBinaryType.java +++ b/jack/src/com/android/jack/ecj/loader/jast/JAstBinaryType.java @@ -91,8 +91,14 @@ class JAstBinaryType implements IBinaryType { modifiers &= ~JModifier.ANONYMOUS_TYPE; JClassOrInterface enclosingType = jDeclaredType.getEnclosingType(); - if (enclosingType != null && !isAnonymous()) { - JAstBinaryType enclosing = classpathLocation.findType(enclosingType); + if (enclosingType != null && !isAnonymous() + && enclosingType instanceof JDefinedClassOrInterface) { + /* If the enclosing is not in the classpath, just skip. This should be with no bad consequence + * since ECJ is refusing to compile a source referencing an inner class when its enclosing + * class is missing. + */ + JAstBinaryType enclosing = + classpathLocation.findType((JDefinedClassOrInterface) enclosingType); if (enclosing != null) { if (LoaderUtils.isDeprecated(enclosing)) { modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; @@ -227,14 +233,18 @@ class JAstBinaryType implements IBinaryType { for (JClassOrInterface jNested : members) { - /* According to a note in a comment on the interface, we have to filter out local types - * found in the member types list. Tests have shown that, in this note, "local" means also - * anonymous. - */ - JAstBinaryType nested = classpathLocation.findType(jNested); - assert nested != null; - if (!(nested.isAnonymous() || nested.isLocal())) { - nestedTypes.add(new JAstBinaryNestedType(nested.jDeclaredType)); + /* If the inner is not in the classpath, just skip it. This should not have consequence in + * Jack context, since we are unable to present the missing class to ECJ anyway. */ + if (jNested instanceof JDefinedClassOrInterface) { + /* According to a note in a comment on the interface, we have to filter out local types + * found in the member types list. Tests have shown that, in this note, "local" means also + * anonymous. + */ + JAstBinaryType nested = classpathLocation.findType((JDefinedClassOrInterface) jNested); + assert nested != null; + if (!(nested.isAnonymous() || nested.isLocal())) { + nestedTypes.add(new JAstBinaryNestedType(nested.jDeclaredType)); + } } } if (!nestedTypes.isEmpty()) { diff --git a/jack/src/com/android/jack/ecj/loader/jast/JAstClasspath.java b/jack/src/com/android/jack/ecj/loader/jast/JAstClasspath.java index b4290c5..60ee5aa 100644 --- a/jack/src/com/android/jack/ecj/loader/jast/JAstClasspath.java +++ b/jack/src/com/android/jack/ecj/loader/jast/JAstClasspath.java @@ -166,8 +166,8 @@ public class JAstClasspath extends ClasspathLocation { } @CheckForNull - JAstBinaryType findType(@Nonnull JType type) { - return new JAstBinaryType((JDefinedClassOrInterface) type, this); + JAstBinaryType findType(@Nonnull JDefinedClassOrInterface type) { + return new JAstBinaryType(type, this); } /** diff --git a/jack/tests/com/android/jack/ClasspathTest.java b/jack/tests/com/android/jack/ClasspathTest.java index 99cd251..dc521c9 100644 --- a/jack/tests/com/android/jack/ClasspathTest.java +++ b/jack/tests/com/android/jack/ClasspathTest.java @@ -16,13 +16,10 @@ package com.android.jack; -import com.android.jack.category.KnownBugs; - import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.File; @@ -95,7 +92,6 @@ public class ClasspathTest { } } - @Category(KnownBugs.class) @Test public void test003() throws Exception { File libOut = TestTools.createTempDir("ClasspathTest", "lib"); |