/** * Get String representation of a Type including Generic information */ public static final String getString(Type type) { if (type instanceof GenericObjectType) { return ((GenericObjectType) type).toString(true); } else if (type instanceof ArrayType) { return TypeCategory.asString((ArrayType) type); } else { return type.toString(); } }
Type type = frame.getInstance(ins, classContext.getConstantPoolGen()); if (type instanceof ReferenceType) { propertySet.setProperty(GeneralWarningProperty.RECEIVER_OBJECT_TYPE, type.toString());
@Test public void testEclipseJDTInvalidUpperBoundSignature() { final Type type = GenericUtilities.getType("!+LHasUniqueKey<Ljava/lang/Integer;>;"); assertThat(type, instanceOf(GenericObjectType.class)); assertEquals("+", ((GenericObjectType) type).getVariable()); assertEquals("HasUniqueKey<java.lang.Integer>", ((GenericObjectType) type).getExtension().toString()); }
@Test public void testEclipseJDTInvalidLowerBoundSignature() { final Type type = GenericUtilities.getType("!-LHasUniqueKey<Ljava/lang/Integer;>;"); assertThat(type, instanceOf(GenericObjectType.class)); assertEquals("-", ((GenericObjectType) type).getVariable()); assertEquals("HasUniqueKey<java.lang.Integer>", ((GenericObjectType) type).getExtension().toString()); }
private JavaType(Type type) { this.name = type.toString(); this.javaClass = null; }
private JavaClassModel[] toJavaClasses(final JavaClassService javaClassService, final Type[] types) { JavaClassModel[] clz = new JavaClassModel[types.length]; for (int i = 0, j = types.length; i < j; i++) { Type t = types[i]; clz[i] = javaClassService.getOrCreatePhantom(t.toString()); } return clz; }
public String toString() { StringBuffer str = new StringBuffer(returnType.getSignature()); str.append( " " ).append( name ).append( "(" ); for(int i = 0; i < parameterTypes.length; i++) { str.append(parameterTypes[i].toString()); if (i > 0) str.append(","); } str.append("),").append((isFinal) ? "f" : "v"); return str.toString(); } }
public static String getCallReturnType(Instruction ins, ConstantPoolGen cp) { if (ins instanceof INVOKESTATIC) { INVOKESTATIC invst = (INVOKESTATIC) ins; return invst.getReturnType(cp).toString(); } else if (ins instanceof INVOKEVIRTUAL) { INVOKEVIRTUAL invst = (INVOKEVIRTUAL) ins; return invst.getReturnType(cp).toString(); } else if (ins instanceof INVOKEINTERFACE) { INVOKEINTERFACE invst = (INVOKEINTERFACE) ins; return invst.getReturnType(cp).toString(); } else if (ins instanceof INVOKESPECIAL) { INVOKESPECIAL invst = (INVOKESPECIAL) ins; return invst.getReturnType(cp).toString(); } else { return null; } }
/** * Get String representation of a Type including Generic information */ public static final String getString(Type type) { if (type instanceof GenericObjectType) { return ((GenericObjectType) type).toString(true); } else if (type instanceof ArrayType) { return TypeCategory.asString((ArrayType) type); } else { return type.toString(); } }
/** * Return string representation close to declaration format, * `public static final short MAX = 100', e.g.. * * @return String representation of field */ public final String toString() { String name, signature, access; // Short cuts to constant pool access = Utility.accessToString(access_flags); access = access.equals("")? "" : (access + " "); signature = type.toString(); name = getName(); StringBuffer buf = new StringBuffer(access + signature + " " + name); String value = getInitValue(); if(value != null) buf.append(" = " + value); return buf.toString(); }
static String printType(String signature) { Type type = Type.getType(signature); byte t = type.getType(); if(t <= Constants.T_VOID) { return "Type." + Constants.TYPE_NAMES[t].toUpperCase(); } else if(type.toString().equals("java.lang.String")) { return "Type.STRING"; } else if(type.toString().equals("java.lang.Object")) { return "Type.OBJECT"; } else if(type.toString().equals("java.lang.StringBuffer")) { return "Type.STRINGBUFFER"; } else if(type instanceof ArrayType) { ArrayType at = (ArrayType)type; return "new ArrayType(" + printType(at.getBasicType()) + ", " + at.getDimensions() + ")"; } else { return "new ObjectType(\"" + Utility.signatureToString(signature, false) + "\")"; } }
static String printType( final String signature ) { final Type type = Type.getType(signature); final byte t = type.getType(); if (t <= Const.T_VOID) { return "Type." + Const.getTypeName(t).toUpperCase(Locale.ENGLISH); } else if (type.toString().equals("java.lang.String")) { return "Type.STRING"; } else if (type.toString().equals("java.lang.Object")) { return "Type.OBJECT"; } else if (type.toString().equals("java.lang.StringBuffer")) { return "Type.STRINGBUFFER"; } else if (type instanceof ArrayType) { final ArrayType at = (ArrayType) type; return "new ArrayType(" + printType(at.getBasicType()) + ", " + at.getDimensions() + ")"; } else { return "new ObjectType(\"" + Utility.signatureToString(signature, false) + "\")"; } }
private boolean isStringClass(ClassGen cg) { if (cg.getMethods().length == 2 && cg.getMethods()[0].isStatic() && cg.getMethods()[1].isStatic()) { if (cg.getMethods()[0].getReturnType().toString().equals( "java.lang.String") && cg.getMethods()[1].getReturnType().toString().equals( "java.lang.String")) { return true; } } return false; }
private boolean isStringClassB(ClassGen cg) { if (cg.getMethods().length == 1 && cg.getMethods()[0].isStatic()) { if (cg.getMethods()[0].getReturnType().toString().equals("java.lang.String")) { return true; } } return false; }
public boolean isAuthClass(ClassGen cg) { if (cg.getMethods().length == 2 && cg.getMethods()[0].getArgumentTypes().length == 1) { if (cg.getMethods()[0].getArgumentTypes()[0].getSignature().contains("String")) { if (cg.getMethods()[0].getReturnType().toString().contains("boolean")) { return true; } } } return false; }
protected static String getField(Type target, String name, Type ret, Type[] args) throws ClassNotFoundException { final JavaClass clazz = Repository.lookupClass(target.toString()); for (Method method : clazz.getMethods()) { if (method.getName().equals(name) && method.getSignature().equals(Type.getMethodSignature(ret, args))) { final Code code = method.getCode(); final Instruction[] instructions = new InstructionList(code.getCode()).getInstructions(); if (instructions.length != 3) throw new Error("Method " + method + " does not have exactly three instruction!"); if (!(instructions[0] instanceof ALOAD) || (((ALOAD) instructions[0]).getIndex() != 0)) throw new Error(); if (!(instructions[instructions.length - 1] instanceof ReturnInstruction)) throw new Error(); final ConstantPoolGen constantPoolGen = new ConstantPoolGen(method.getConstantPool()); final GETFIELD get = ((GETFIELD) instructions[1]); return get.getFieldName(constantPoolGen); } } throw new Error(); }
public void setDecryptor() { for (ClassGen cg : cgs.values()) { for (Method m : cg.getMethods()) { try { if (m.isPublic() && m.isStatic() && m.getArgumentTypes()[0].toString().equals("java.lang.String") && m.getReturnType().toString().equals("java.lang.String")) { String dc = cg.getClassName() + "." + m.getName(); decryptor = m.getName(); decryptorclass = cg.getClassName(); logger.debug("Found String Decryptor! " + dc); return; } } catch (Exception e) { continue; } } } logger.error("String decrypt not found!"); }
private void addFieldTypeAsJsField(VariableDeclaration decl, String assignmentOperator) { if (assignmentOperator.equals(":")) { print(", $T$" + decl.getName()); print(" : "); print("\""); Type type= decl.getType(); if (type instanceof ArrayType) { print(type.getSignature().replaceAll("/", ".")); } else print(type.toString()); print("\""); } }
public boolean isLoader(ClassGen cg) { return cg.getMethods().length == 3 && cg.getMethods()[1].isStatic() && cg.getMethods()[1].isFinal() && cg.getMethods()[1].isPublic() && cg.getMethods()[1].isSynchronized() && cg.getMethods()[1].getReturnType().toString().equals("java.lang.String"); }
public void visit(CastExpression cast) { if (cast.getTypeBinding() != Type.VOID && DragomeJsCompiler.compiler.compilerConfiguration.isCheckingCast()) { print("dragomeJs.checkCast("); cast.getExpression().visit(this); String string= cast.getTypeBinding().toString(); String normalizeExpression= normalizeExpression(string); if (string.startsWith("[L")) normalizeExpression= "'" + string + "'"; print("," + normalizeExpression + ")"); } else { // TODO: Is it correct to remove casts to void (i.e. pop)? // print("void "); cast.getExpression().visit(this); } }