in proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/common/OSGiFriendlyClassWriter.java [61:126]
protected final String getCommonSuperClass(String arg0, String arg1) {
//If either is Object, then Object must be the answer
if(arg0.equals(OBJECT_INTERNAL_NAME) || arg1.equals(OBJECT_INTERNAL_NAME)) {
return OBJECT_INTERNAL_NAME;
}
Set<String> names = new HashSet<String>();
names.add(arg0);
names.add(arg1);
//Try loading the class (in ASM not for real)
try {
boolean bRunning = true;
boolean aRunning = true;
InputStream is;
String arg00 = arg0;
String arg11 = arg1;
String unable = null;
while(aRunning || bRunning ) {
if(aRunning) {
is = loader.getResourceAsStream(arg00 + ".class");
if(is != null) {
ClassReader cr = new ClassReader(is);
arg00 = cr.getSuperName();
if(arg00 == null) {
if (names.size() == 2) {
return OBJECT_INTERNAL_NAME; //arg0 is an interface
}
aRunning = false; //old arg00 was java.lang.Object
} else if(!names.add(arg00)) {
return arg00;
}
} else {
//The class file isn't visible on this ClassLoader
unable = arg0;
aRunning = false;
}
}
if(bRunning) {
is = loader.getResourceAsStream(arg11 + ".class");
if(is != null) {
ClassReader cr = new ClassReader(is);
arg11 = cr.getSuperName();
if(arg11 == null) {
if (names.size() == 3) {
return OBJECT_INTERNAL_NAME; //arg1 is an interface
}
bRunning = false; //old arg11 was java.lang.Object
} else if(!names.add(arg11)) {
return arg11;
}
} else {
unable = arg1;
bRunning = false;
}
}
}
String msg = String.format("The class %s and %s do not have a common super class.", arg0, arg1);
if (unable == null) {
throw new RuntimeException(msg);
} else {
throw new RuntimeException(new UnableToProxyException(unable, msg));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}