mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Fix StrucType.isSubTypeOf() for sub interfaces.
This commit is contained in:
parent
6294172dbc
commit
60d24f2feb
@ -1015,24 +1015,21 @@ public class TypeManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
ClassFile classFile = manager.classFileLoader.get( name );
|
ClassFile classFile = manager.classFileLoader.get( name );
|
||||||
if( classFile != null ) {
|
String otherTypeName = structType.name;
|
||||||
for( ConstantClass interClass : classFile.getInterfaces() ) {
|
while( classFile != null ) {
|
||||||
if( interClass.getName().equals( structType.name ) ) {
|
if( isSubTypeOf( classFile, otherTypeName )) {
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while( classFile != null ) {
|
ConstantClass superClass = classFile.getSuperClass();
|
||||||
ConstantClass superClass = classFile.getSuperClass();
|
if( superClass == null ) {
|
||||||
if( superClass == null ) {
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
String superName = superClass.getName();
|
|
||||||
if( superName.equals( structType.name ) ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
classFile = manager.classFileLoader.get( superName );
|
|
||||||
}
|
}
|
||||||
|
String superName = superClass.getName();
|
||||||
|
if( superName.equals( otherTypeName ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
classFile = manager.classFileLoader.get( superName );
|
||||||
}
|
}
|
||||||
} catch( IOException ex ) {
|
} catch( IOException ex ) {
|
||||||
throw new UncheckedIOException( ex );
|
throw new UncheckedIOException( ex );
|
||||||
@ -1041,6 +1038,30 @@ public class TypeManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for sub interface recursively.
|
||||||
|
*
|
||||||
|
* @param classFile
|
||||||
|
* the class file to check
|
||||||
|
* @param otherTypeName
|
||||||
|
* the searching interface name
|
||||||
|
* @return true, if a sub interface
|
||||||
|
* @throws IOException
|
||||||
|
* If any I/O error occur
|
||||||
|
*/
|
||||||
|
private boolean isSubTypeOf( ClassFile classFile, String otherTypeName ) throws IOException {
|
||||||
|
for( ConstantClass iface : classFile.getInterfaces() ) {
|
||||||
|
if( iface.getName().equals( otherTypeName ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ClassFile iClassFile = manager.classFileLoader.get( iface.getName() );
|
||||||
|
if( iClassFile != null && isSubTypeOf( iClassFile, otherTypeName ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get kind of the StructType
|
* Get kind of the StructType
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user