return classPath.getUnknownClass(); return classPath.getUnknownClass();
@Nullable public static TypeProto getSuperclassAsTypeProto(@Nonnull TypeProto type) { try { String next = type.getSuperclass(); if (next != null) { return type.getClassPath().getClass(next); } else { return null; } } catch (UnresolvedClassException ex) { return type.getClassPath().getUnknownClass(); } }
@Nullable public static TypeProto getSuperclassAsTypeProto(@Nonnull TypeProto type) { try { String next = type.getSuperclass(); if (next != null) { return type.getClassPath().getClass(next); } else { return null; } } catch (UnresolvedClassException ex) { return type.getClassPath().getUnknownClass(); } }
@Nullable public static TypeProto getSuperclassAsTypeProto(@Nonnull TypeProto type) { try { String next = type.getSuperclass(); if (next != null) { return type.getClassPath().getClass(next); } else { return null; } } catch (UnresolvedClassException ex) { return type.getClassPath().getUnknownClass(); } } }
return classPath.getUnknownClass(); return classPath.getUnknownClass();
return classPath.getUnknownClass(); return classPath.getUnknownClass();
@Test public void testGetSuperclassChain_Unresolved() throws IOException { // Ltest/one; isn't defined ClassDef twoClassDef = TestUtils.makeClassDef("Ltest/two;", "Ltest/one;"); ClassDef threeClassDef = TestUtils.makeClassDef("Ltest/three;", "Ltest/two;"); ImmutableSet<ClassDef> classes = ImmutableSet.<ClassDef>of(twoClassDef, threeClassDef); ClassPath classPath = new ClassPath(new DexClassProvider(new ImmutableDexFile(Opcodes.getDefault(), classes))); TypeProto unknownClassProto = classPath.getUnknownClass(); TypeProto oneClassProto = classPath.getClass("Ltest/one;"); TypeProto twoClassProto = classPath.getClass("Ltest/two;"); TypeProto threeClassProto = classPath.getClass("Ltest/three;"); Assert.assertEquals( ImmutableList.<TypeProto>of(oneClassProto, unknownClassProto), ImmutableList.copyOf(TypeProtoUtils.getSuperclassChain(twoClassProto))); Assert.assertEquals( ImmutableList.<TypeProto>of(twoClassProto, oneClassProto, unknownClassProto), ImmutableList.copyOf(TypeProtoUtils.getSuperclassChain(threeClassProto))); } }