Package com.ibm.wala.classLoader
Class JavaLanguage
- java.lang.Object
-
- com.ibm.wala.classLoader.LanguageImpl
-
- com.ibm.wala.classLoader.JavaLanguage
-
- All Implemented Interfaces:
BytecodeLanguage
,Language
,Constants
public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Constants
The implementation ofLanguage
which defines Java semantics.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JavaLanguage.JavaInstructionFactory
-
Field Summary
-
Fields inherited from interface com.ibm.wala.shrikeBT.Constants
ACC_ABSTRACT, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_TRANSIENT, ACC_VOLATILE, CONSTANT_Class, CONSTANT_Double, CONSTANT_FieldRef, CONSTANT_Float, CONSTANT_Integer, CONSTANT_InterfaceMethodRef, CONSTANT_InvokeDynamic, CONSTANT_Long, CONSTANT_MethodHandle, CONSTANT_MethodRef, CONSTANT_MethodType, CONSTANT_NameAndType, CONSTANT_String, CONSTANT_Utf8, indexedTypes, indexedTypes_T, MAYBE, NO, OP_aaload, OP_aastore, OP_aconst_null, OP_aload, OP_aload_0, OP_aload_1, OP_aload_2, OP_aload_3, OP_anewarray, OP_areturn, OP_arraylength, OP_astore, OP_astore_0, OP_astore_1, OP_astore_2, OP_astore_3, OP_athrow, OP_baload, OP_bastore, OP_bipush, OP_caload, OP_castore, OP_checkcast, OP_d2f, OP_d2i, OP_d2l, OP_dadd, OP_daload, OP_dastore, OP_dcmpg, OP_dcmpl, OP_dconst_0, OP_dconst_1, OP_ddiv, OP_dload, OP_dload_0, OP_dload_1, OP_dload_2, OP_dload_3, OP_dmul, OP_dneg, OP_drem, OP_dreturn, OP_dstore, OP_dstore_0, OP_dstore_1, OP_dstore_2, OP_dstore_3, OP_dsub, OP_dup, OP_dup_x1, OP_dup_x2, OP_dup2, OP_dup2_x1, OP_dup2_x2, OP_f2d, OP_f2i, OP_f2l, OP_fadd, OP_faload, OP_fastore, OP_fcmpg, OP_fcmpl, OP_fconst_0, OP_fconst_1, OP_fconst_2, OP_fdiv, OP_fload, OP_fload_0, OP_fload_1, OP_fload_2, OP_fload_3, OP_fmul, OP_fneg, OP_frem, OP_freturn, OP_fstore, OP_fstore_0, OP_fstore_1, OP_fstore_2, OP_fstore_3, OP_fsub, OP_getfield, OP_getstatic, OP_goto, OP_goto_w, OP_i2b, OP_i2c, OP_i2d, OP_i2f, OP_i2l, OP_i2s, OP_iadd, OP_iaload, OP_iand, OP_iastore, OP_iconst_0, OP_iconst_1, OP_iconst_2, OP_iconst_3, OP_iconst_4, OP_iconst_5, OP_iconst_m1, OP_idiv, OP_if_acmpeq, OP_if_acmpne, OP_if_icmpeq, OP_if_icmpge, OP_if_icmpgt, OP_if_icmple, OP_if_icmplt, OP_if_icmpne, OP_ifeq, OP_ifge, OP_ifgt, OP_ifle, OP_iflt, OP_ifne, OP_ifnonnull, OP_ifnull, OP_iinc, OP_iload, OP_iload_0, OP_iload_1, OP_iload_2, OP_iload_3, OP_imul, OP_ineg, OP_instanceof, OP_invokedynamic, OP_invokeinterface, OP_invokespecial, OP_invokestatic, OP_invokevirtual, OP_ior, OP_irem, OP_ireturn, OP_ishl, OP_ishr, OP_istore, OP_istore_0, OP_istore_1, OP_istore_2, OP_istore_3, OP_isub, OP_iushr, OP_ixor, OP_jsr, OP_jsr_w, OP_l2d, OP_l2f, OP_l2i, OP_ladd, OP_laload, OP_land, OP_lastore, OP_lcmp, OP_lconst_0, OP_lconst_1, OP_ldc, OP_ldc_w, OP_ldc2_w, OP_ldiv, OP_lload, OP_lload_0, OP_lload_1, OP_lload_2, OP_lload_3, OP_lmul, OP_lneg, OP_lookupswitch, OP_lor, OP_lrem, OP_lreturn, OP_lshl, OP_lshr, OP_lstore, OP_lstore_0, OP_lstore_1, OP_lstore_2, OP_lstore_3, OP_lsub, OP_lushr, OP_lxor, OP_monitorenter, OP_monitorexit, OP_multianewarray, OP_new, OP_newarray, OP_nop, OP_pop, OP_pop2, OP_putfield, OP_putstatic, OP_ret, OP_return, OP_saload, OP_sastore, OP_sipush, OP_swap, OP_tableswitch, OP_wide, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TYPE_boolean, TYPE_boolean_index, TYPE_byte, TYPE_byte_index, TYPE_char, TYPE_char_index, TYPE_Class, TYPE_double, TYPE_double_index, TYPE_Error, TYPE_Exception, TYPE_float, TYPE_float_index, TYPE_int, TYPE_int_index, TYPE_long, TYPE_long_index, TYPE_MethodHandle, TYPE_MethodType, TYPE_null, TYPE_Object, TYPE_Object_index, TYPE_RuntimeException, TYPE_short, TYPE_short_index, TYPE_String, TYPE_Throwable, TYPE_unknown, TYPE_void, YES
-
-
Constructor Summary
Constructors Constructor Description JavaLanguage()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Collection<TypeReference>
getAaStoreExceptions()
static Collection<TypeReference>
getArithmeticException()
static Collection<TypeReference>
getArrayAccessExceptions()
TypeReference[]
getArrayInterfaces()
get the interfaces implemented by all arrays in the languagestatic Collection<TypeReference>
getClassCastException()
static Collection<TypeReference>
getClassNotFoundException()
TypeReference
getConstantType(Object o)
Given a Java constant o, return the appropriate language type to associate with the constant.static Collection<TypeReference>
getExceptionInInitializerError()
Collection<TypeReference>
getImplicitExceptionTypes(IInstruction pei)
MethodReference
getInvokeMethodReference(ClassLoaderReference loader, IInvokeInstruction instruction)
Object
getMetadataToken(Object value)
Get the representation of the meta-data corresponding to value.Atom
getName()
What is the name of the language?static Collection<TypeReference>
getNewArrayExceptions()
static Collection<TypeReference>
getNewScalarExceptions()
static Collection<TypeReference>
getNullPointerException()
TypeReference
getPointerType(TypeReference pointee)
PrimitiveType
getPrimitive(TypeReference reference)
get the abstraction of a primitive type to be used for type inferenceTypeReference
getRootType()
What is the root type in a type hierarchy for this language? e.g.TypeReference
getStringType()
TypeReference
getThrowableType()
What is the root type of exceptions in this language? e.g.Collection<TypeReference>
inferInvokeExceptions(MethodReference target, IClassHierarchy cha)
determine the set of possible exception types a call to target may throwSSAInstructionFactory
instructionFactory()
boolean
isBooleanType(TypeReference type)
boolean
isCharType(TypeReference type)
boolean
isDoubleType(TypeReference type)
boolean
isFloatType(TypeReference type)
boolean
isIntType(TypeReference type)
boolean
isLongType(TypeReference type)
boolean
isMetadataType(TypeReference type)
Is t a "metadata" type for the language, i.e., a type describing some other type (e.g., java.lang.Class for Java)?boolean
isNullType(TypeReference type)
Is t the type of the language's null value? Should return true ift == null
(?).boolean
isStringType(TypeReference type)
boolean
isVoidType(TypeReference type)
TypeName
lookupPrimitiveType(String name)
Given a source-level primitive type name, get the corresponding "low-level" type name, e.g., the corresponding character to use in a Java method descriptor-
Methods inherited from class com.ibm.wala.classLoader.LanguageImpl
equals, getBaseLanguage, getDerivedLanguages, hashCode, registerDerivedLanguage, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.ibm.wala.classLoader.Language
getBaseLanguage, getDerivedLanguages, registerDerivedLanguage
-
-
-
-
Method Detail
-
getAaStoreExceptions
public static Collection<TypeReference> getAaStoreExceptions()
-
getArithmeticException
public static Collection<TypeReference> getArithmeticException()
-
getArrayAccessExceptions
public static Collection<TypeReference> getArrayAccessExceptions()
-
getClassCastException
public static Collection<TypeReference> getClassCastException()
-
getClassNotFoundException
public static Collection<TypeReference> getClassNotFoundException()
-
getNewArrayExceptions
public static Collection<TypeReference> getNewArrayExceptions()
-
getNewScalarExceptions
public static Collection<TypeReference> getNewScalarExceptions()
-
getNullPointerException
public static Collection<TypeReference> getNullPointerException()
-
getExceptionInInitializerError
public static Collection<TypeReference> getExceptionInInitializerError()
-
getName
public Atom getName()
Description copied from interface:Language
What is the name of the language?
-
getRootType
public TypeReference getRootType()
Description copied from interface:Language
What is the root type in a type hierarchy for this language? e.g. java.lang.Object in Java.- Specified by:
getRootType
in interfaceLanguage
-
getThrowableType
public TypeReference getThrowableType()
Description copied from interface:Language
What is the root type of exceptions in this language? e.g. java.lang.Throwable in Java- Specified by:
getThrowableType
in interfaceLanguage
-
getConstantType
public TypeReference getConstantType(Object o)
Description copied from interface:Language
Given a Java constant o, return the appropriate language type to associate with the constant. Possible types for o can be language dependent, but typically include Boolean, String, Integer, Float, etc.- Specified by:
getConstantType
in interfaceLanguage
-
isNullType
public boolean isNullType(TypeReference type)
Description copied from interface:Language
Is t the type of the language's null value? Should return true ift == null
(?).- Specified by:
isNullType
in interfaceLanguage
-
getArrayInterfaces
public TypeReference[] getArrayInterfaces()
Description copied from interface:Language
get the interfaces implemented by all arrays in the language- Specified by:
getArrayInterfaces
in interfaceLanguage
-
lookupPrimitiveType
public TypeName lookupPrimitiveType(String name)
Description copied from interface:Language
Given a source-level primitive type name, get the corresponding "low-level" type name, e.g., the corresponding character to use in a Java method descriptor- Specified by:
lookupPrimitiveType
in interfaceLanguage
-
inferInvokeExceptions
public Collection<TypeReference> inferInvokeExceptions(MethodReference target, IClassHierarchy cha) throws InvalidClassFileException
Description copied from interface:Language
determine the set of possible exception types a call to target may throw- Specified by:
inferInvokeExceptions
in interfaceLanguage
- Returns:
- Collection
, set of exception types a call to a declared target might throw. - Throws:
InvalidClassFileException
IllegalArgumentException
- if target is nullIllegalArgumentException
- if cha is null
-
getImplicitExceptionTypes
public Collection<TypeReference> getImplicitExceptionTypes(IInstruction pei)
- Specified by:
getImplicitExceptionTypes
in interfaceBytecodeLanguage
- Parameters:
pei
- a potentially-excepting instruction- Returns:
- the exception types that pei may throw, independent of the class hierarchy. null if none.
Notes
- this method will NOT return the exception type explicitly thrown by an athrow
- this method will NOT return the exception types that a called method may throw
- this method ignores OutOfMemoryError
- this method ignores linkage errors
- this method ignores IllegalMonitorState exceptions
- Throws:
IllegalArgumentException
- if pei is null
-
instructionFactory
public SSAInstructionFactory instructionFactory()
- Specified by:
instructionFactory
in interfaceLanguage
-
isDoubleType
public boolean isDoubleType(TypeReference type)
- Specified by:
isDoubleType
in interfaceLanguage
-
isFloatType
public boolean isFloatType(TypeReference type)
- Specified by:
isFloatType
in interfaceLanguage
-
isIntType
public boolean isIntType(TypeReference type)
-
isLongType
public boolean isLongType(TypeReference type)
- Specified by:
isLongType
in interfaceLanguage
-
isVoidType
public boolean isVoidType(TypeReference type)
- Specified by:
isVoidType
in interfaceLanguage
-
isMetadataType
public boolean isMetadataType(TypeReference type)
Description copied from interface:Language
Is t a "metadata" type for the language, i.e., a type describing some other type (e.g., java.lang.Class for Java)?- Specified by:
isMetadataType
in interfaceLanguage
-
isStringType
public boolean isStringType(TypeReference type)
- Specified by:
isStringType
in interfaceLanguage
-
isBooleanType
public boolean isBooleanType(TypeReference type)
- Specified by:
isBooleanType
in interfaceLanguage
-
isCharType
public boolean isCharType(TypeReference type)
- Specified by:
isCharType
in interfaceLanguage
-
getMetadataToken
public Object getMetadataToken(Object value)
Description copied from interface:Language
Get the representation of the meta-data corresponding to value. For example, in Java, if value represents some type, the returned object should be the correspondingTypeReference
. The returned object should be appropriate for use as the token in anSSALoadMetadataInstruction
for the language- Specified by:
getMetadataToken
in interfaceLanguage
-
getPointerType
public TypeReference getPointerType(TypeReference pointee) throws UnsupportedOperationException
- Specified by:
getPointerType
in interfaceLanguage
- Throws:
UnsupportedOperationException
-
getStringType
public TypeReference getStringType()
- Specified by:
getStringType
in interfaceLanguage
-
getPrimitive
public PrimitiveType getPrimitive(TypeReference reference)
Description copied from interface:Language
get the abstraction of a primitive type to be used for type inference- Specified by:
getPrimitive
in interfaceLanguage
- See Also:
TypeInference
-
getInvokeMethodReference
public MethodReference getInvokeMethodReference(ClassLoaderReference loader, IInvokeInstruction instruction)
- Specified by:
getInvokeMethodReference
in interfaceBytecodeLanguage
-
-