@ -45,7 +45,8 @@ import @COLLECTIONS@.ListIterator;
*
* @author Jochen Hoenicke
* /
public class ConstantAnalyzer implements Opcodes , CodeAnalyzer {
public class ConstantAnalyzer extends SimpleAnalyzer
implements Opcodes , CodeAnalyzer {
BytecodeInfo bytecode ;
@ -517,74 +518,6 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer {
( ( StackLocalInfo ) instr . getTmpInfo ( ) ) . merge ( info ) ;
}
private ClassInfo canonizeIfaceRef ( ClassInfo clazz , Reference ref ) {
while ( clazz ! = null ) {
if ( clazz . findMethod ( ref . getName ( ) , ref . getType ( ) ) ! = null )
return clazz ;
ClassInfo [ ] ifaces = clazz . getInterfaces ( ) ;
for ( int i = 0 ; i < ifaces . length ; i + + ) {
ClassInfo realClass = canonizeIfaceRef ( ifaces [ i ] , ref ) ;
if ( realClass ! = null )
return realClass ;
}
clazz = clazz . getSuperclass ( ) ;
}
return null ;
}
public Identifier canonizeReference ( Instruction instr ) {
Reference ref = instr . getReference ( ) ;
Identifier ident = Main . getClassBundle ( ) . getIdentifier ( ref ) ;
String clName = ref . getClazz ( ) ;
String realClazzName ;
if ( ident ! = null ) {
ClassIdentifier clazz = ( ClassIdentifier ) ident . getParent ( ) ;
realClazzName = "L" + ( clazz . getFullName ( )
. replace ( '.' , '/' ) ) + ";" ;
} else {
/ * We have to look at the ClassInfo ' s instead , to
* point to the right method .
* /
ClassInfo clazz ;
if ( clName . charAt ( 0 ) = = '[' ) {
/ * Arrays don ' t define new methods ( well clone ( ) ,
* but that can be ignored ) .
* /
clazz = ClassInfo . javaLangObject ;
} else {
clazz = ClassInfo . forName
( clName . substring ( 1 , clName . length ( ) - 1 )
. replace ( '/' , '.' ) ) ;
}
if ( instr . getOpcode ( ) = = opc_invokeinterface ) {
clazz = canonizeIfaceRef ( clazz , ref ) ;
} else if ( instr . getOpcode ( ) > = opc_invokevirtual ) {
while ( clazz ! = null
& & clazz . findMethod ( ref . getName ( ) ,
ref . getType ( ) ) = = null )
clazz = clazz . getSuperclass ( ) ;
} else {
while ( clazz ! = null
& & clazz . findField ( ref . getName ( ) ,
ref . getType ( ) ) = = null )
clazz = clazz . getSuperclass ( ) ;
}
if ( clazz = = null ) {
GlobalOptions . err . println ( "WARNING: Can't find reference: "
+ ref ) ;
realClazzName = clName ;
} else
realClazzName = "L" + clazz . getName ( ) . replace ( '.' , '/' ) + ";" ;
}
if ( ! realClazzName . equals ( ref . getClazz ( ) ) ) {
ref = Reference . getReference ( realClazzName ,
ref . getName ( ) , ref . getType ( ) ) ;
instr . setReference ( ref ) ;
}
return ident ;
}
public void handleReference ( Reference ref , boolean isVirtual ) {
Main . getClassBundle ( ) . reachableReference ( ref , isVirtual ) ;
}