Java Code Examples for jdk.internal.org.objectweb.asm.Type#equals()
The following examples show how to use
jdk.internal.org.objectweb.asm.Type#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleVerifier.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override protected boolean isSubTypeOf(final BasicValue value, final BasicValue expected) { Type expectedType = expected.getType(); Type type = value.getType(); switch (expectedType.getSort()) { case Type.INT: case Type.FLOAT: case Type.LONG: case Type.DOUBLE: return type.equals(expectedType); case Type.ARRAY: case Type.OBJECT: if ("Lnull;".equals(type.getDescriptor())) { return true; } else if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { return isAssignableFrom(expectedType, type); } else { return false; } default: throw new Error("Internal error"); } }
Example 2
Source File: SimpleVerifier.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
protected boolean isAssignableFrom(final Type t, final Type u) { if (t.equals(u)) { return true; } if (currentClass != null && t.equals(currentClass)) { if (getSuperClass(u) == null) { return false; } else { if (isInterface) { return u.getSort() == Type.OBJECT || u.getSort() == Type.ARRAY; } return isAssignableFrom(t, getSuperClass(u)); } } if (currentClass != null && u.equals(currentClass)) { if (isAssignableFrom(t, currentSuperClass)) { return true; } if (currentClassInterfaces != null) { for (int i = 0; i < currentClassInterfaces.size(); ++i) { Type v = currentClassInterfaces.get(i); if (isAssignableFrom(t, v)) { return true; } } } return false; } Class<?> tc = getClass(t); if (tc.isInterface()) { tc = Object.class; } return tc.isAssignableFrom(getClass(u)); }
Example 3
Source File: SimpleVerifier.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
protected boolean isAssignableFrom(final Type t, final Type u) { if (t.equals(u)) { return true; } if (currentClass != null && t.equals(currentClass)) { if (getSuperClass(u) == null) { return false; } else { if (isInterface) { return u.getSort() == Type.OBJECT || u.getSort() == Type.ARRAY; } return isAssignableFrom(t, getSuperClass(u)); } } if (currentClass != null && u.equals(currentClass)) { if (isAssignableFrom(t, currentSuperClass)) { return true; } if (currentClassInterfaces != null) { for (int i = 0; i < currentClassInterfaces.size(); ++i) { Type v = currentClassInterfaces.get(i); if (isAssignableFrom(t, v)) { return true; } } } return false; } Class<?> tc = getClass(t); if (tc.isInterface()) { tc = Object.class; } return tc.isAssignableFrom(getClass(u)); }
Example 4
Source File: SimpleVerifier.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
protected boolean isAssignableFrom(final Type t, final Type u) { if (t.equals(u)) { return true; } if (currentClass != null && t.equals(currentClass)) { if (getSuperClass(u) == null) { return false; } else { if (isInterface) { return u.getSort() == Type.OBJECT || u.getSort() == Type.ARRAY; } return isAssignableFrom(t, getSuperClass(u)); } } if (currentClass != null && u.equals(currentClass)) { if (isAssignableFrom(t, currentSuperClass)) { return true; } if (currentClassInterfaces != null) { for (int i = 0; i < currentClassInterfaces.size(); ++i) { Type v = currentClassInterfaces.get(i); if (isAssignableFrom(t, v)) { return true; } } } return false; } Class<?> tc = getClass(t); if (tc.isInterface()) { tc = Object.class; } return tc.isAssignableFrom(getClass(u)); }
Example 5
Source File: SimpleVerifier.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
protected boolean isAssignableFrom(final Type t, final Type u) { if (t.equals(u)) { return true; } if (currentClass != null && t.equals(currentClass)) { if (getSuperClass(u) == null) { return false; } else { if (isInterface) { return u.getSort() == Type.OBJECT || u.getSort() == Type.ARRAY; } return isAssignableFrom(t, getSuperClass(u)); } } if (currentClass != null && u.equals(currentClass)) { if (isAssignableFrom(t, currentSuperClass)) { return true; } if (currentClassInterfaces != null) { for (int i = 0; i < currentClassInterfaces.size(); ++i) { Type v = currentClassInterfaces.get(i); if (isAssignableFrom(t, v)) { return true; } } } return false; } Class<?> tc = getClass(t); if (tc.isInterface()) { tc = Object.class; } return tc.isAssignableFrom(getClass(u)); }
Example 6
Source File: SimpleVerifier.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected Type getSuperClass(final Type t) { if (currentClass != null && t.equals(currentClass)) { return currentSuperClass; } Class<?> c = getClass(t).getSuperclass(); return c == null ? null : Type.getType(c); }
Example 7
Source File: SimpleVerifier.java From hottub with GNU General Public License v2.0 | 5 votes |
protected Type getSuperClass(final Type t) { if (currentClass != null && t.equals(currentClass)) { return currentSuperClass; } Class<?> c = getClass(t).getSuperclass(); return c == null ? null : Type.getType(c); }
Example 8
Source File: SimpleVerifier.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected boolean isAssignableFrom(final Type t, final Type u) { if (t.equals(u)) { return true; } if (currentClass != null && t.equals(currentClass)) { if (getSuperClass(u) == null) { return false; } else { if (isInterface) { return u.getSort() == Type.OBJECT || u.getSort() == Type.ARRAY; } return isAssignableFrom(t, getSuperClass(u)); } } if (currentClass != null && u.equals(currentClass)) { if (isAssignableFrom(t, currentSuperClass)) { return true; } if (currentClassInterfaces != null) { for (int i = 0; i < currentClassInterfaces.size(); ++i) { Type v = currentClassInterfaces.get(i); if (isAssignableFrom(t, v)) { return true; } } } return false; } Class<?> tc = getClass(t); if (tc.isInterface()) { tc = Object.class; } return tc.isAssignableFrom(getClass(u)); }
Example 9
Source File: SimpleVerifier.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected Type getSuperClass(final Type t) { if (currentClass != null && t.equals(currentClass)) { return currentSuperClass; } Class<?> c = getClass(t).getSuperclass(); return c == null ? null : Type.getType(c); }
Example 10
Source File: SimpleVerifier.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Returns whether the class corresponding to the first argument is either the same as, or is a * superclass or superinterface of the class corresponding to the second argument. The default * implementation of this method loads the classes and uses the reflection API to return its * result (unless the result can be computed from the class being verified, and the types of its * super classes and implemented interfaces). * * @param type1 a type. * @param type2 another type. * @return whether the class corresponding to 'type1' is either the same as, or is a superclass or * superinterface of the class corresponding to 'type2'. */ protected boolean isAssignableFrom(final Type type1, final Type type2) { if (type1.equals(type2)) { return true; } if (currentClass != null && currentClass.equals(type1)) { if (getSuperClass(type2) == null) { return false; } else { if (isInterface) { return type2.getSort() == Type.OBJECT || type2.getSort() == Type.ARRAY; } return isAssignableFrom(type1, getSuperClass(type2)); } } if (currentClass != null && currentClass.equals(type2)) { if (isAssignableFrom(type1, currentSuperClass)) { return true; } if (currentClassInterfaces != null) { for (Type currentClassInterface : currentClassInterfaces) { if (isAssignableFrom(type1, currentClassInterface)) { return true; } } } return false; } return getClass(type1).isAssignableFrom(getClass(type2)); }
Example 11
Source File: SimpleVerifier.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
protected boolean isInterface(final Type t) { if (currentClass != null && t.equals(currentClass)) { return isInterface; } return getClass(t).isInterface(); }
Example 12
Source File: SimpleVerifier.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
protected boolean isInterface(final Type t) { if (currentClass != null && t.equals(currentClass)) { return isInterface; } return getClass(t).isInterface(); }
Example 13
Source File: SimpleVerifier.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
protected boolean isInterface(final Type t) { if (currentClass != null && t.equals(currentClass)) { return isInterface; } return getClass(t).isInterface(); }
Example 14
Source File: SimpleVerifier.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
protected boolean isInterface(final Type t) { if (currentClass != null && t.equals(currentClass)) { return isInterface; } return getClass(t).isInterface(); }
Example 15
Source File: SimpleVerifier.java From Bytecoder with Apache License 2.0 | 4 votes |
@Override public BasicValue merge(final BasicValue value1, final BasicValue value2) { if (!value1.equals(value2)) { Type type1 = value1.getType(); Type type2 = value2.getType(); if (type1 != null && (type1.getSort() == Type.OBJECT || type1.getSort() == Type.ARRAY) && type2 != null && (type2.getSort() == Type.OBJECT || type2.getSort() == Type.ARRAY)) { if (type1.equals(NULL_TYPE)) { return value2; } if (type2.equals(NULL_TYPE)) { return value1; } if (isAssignableFrom(type1, type2)) { return value1; } if (isAssignableFrom(type2, type1)) { return value2; } int numDimensions = 0; if (type1.getSort() == Type.ARRAY && type2.getSort() == Type.ARRAY && type1.getDimensions() == type2.getDimensions() && type1.getElementType().getSort() == Type.OBJECT && type2.getElementType().getSort() == Type.OBJECT) { numDimensions = type1.getDimensions(); type1 = type1.getElementType(); type2 = type2.getElementType(); } do { if (type1 == null || isInterface(type1)) { return newArrayValue(Type.getObjectType("java/lang/Object"), numDimensions); } type1 = getSuperClass(type1); if (isAssignableFrom(type1, type2)) { return newArrayValue(type1, numDimensions); } } while (true); } return BasicValue.UNINITIALIZED_VALUE; } return value1; }
Example 16
Source File: SimpleVerifier.java From Bytecoder with Apache License 2.0 | 4 votes |
@Override protected boolean isArrayValue(final BasicValue value) { Type type = value.getType(); return type != null && (type.getSort() == Type.ARRAY || type.equals(NULL_TYPE)); }
Example 17
Source File: SimpleVerifier.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
protected boolean isInterface(final Type t) { if (currentClass != null && t.equals(currentClass)) { return isInterface; } return getClass(t).isInterface(); }
Example 18
Source File: SimpleVerifier.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
protected boolean isInterface(final Type t) { if (currentClass != null && t.equals(currentClass)) { return isInterface; } return getClass(t).isInterface(); }
Example 19
Source File: JavaAdapterBytecodeGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private void convertReturnValue(final InstructionAdapter mv, final Class<?> returnType, final Type asmReturnType) { switch(asmReturnType.getSort()) { case Type.VOID: mv.pop(); break; case Type.BOOLEAN: JSType.TO_BOOLEAN.invoke(mv); break; case Type.BYTE: JSType.TO_INT32.invoke(mv); mv.visitInsn(Opcodes.I2B); break; case Type.SHORT: JSType.TO_INT32.invoke(mv); mv.visitInsn(Opcodes.I2S); break; case Type.CHAR: // JSType doesn't have a TO_CHAR, so we have services supply us one. mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "toCharPrimitive", TO_CHAR_PRIMITIVE_METHOD_DESCRIPTOR, false); break; case Type.INT: JSType.TO_INT32.invoke(mv); break; case Type.LONG: JSType.TO_LONG.invoke(mv); break; case Type.FLOAT: JSType.TO_NUMBER.invoke(mv); mv.visitInsn(Opcodes.D2F); break; case Type.DOUBLE: JSType.TO_NUMBER.invoke(mv); break; default: if(asmReturnType.equals(OBJECT_TYPE)) { // Must hide ConsString (and potentially other internal Nashorn types) from callers mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "exportReturnValue", EXPORT_RETURN_VALUE_METHOD_DESCRIPTOR, false); } else if(asmReturnType.equals(STRING_TYPE)){ // Well-known conversion to String. Not using the JSType one as we want to preserve null as null instead // of the string "n,u,l,l". mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "toString", TO_STRING_METHOD_DESCRIPTOR, false); } else { // Invoke converter method handle for everything else. Note that we could have just added an asType or // filterReturnValue to the invoked handle instead, but then every instance would have the function // method handle wrapped in a separate converter method handle, making handle.invokeExact() megamorphic. if(classOverride) { mv.getstatic(generatedClassName, converterFields.get(returnType), METHOD_HANDLE_TYPE_DESCRIPTOR); } else { mv.visitVarInsn(ALOAD, 0); mv.getfield(generatedClassName, converterFields.get(returnType), METHOD_HANDLE_TYPE_DESCRIPTOR); } mv.swap(); emitInvokeExact(mv, MethodType.methodType(returnType, Object.class)); } } }
Example 20
Source File: GeneratorAdapter.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Generates the instruction to check that the top stack value is of the * given type. * * @param type * a class or interface type. */ public void checkCast(final Type type) { if (!type.equals(OBJECT_TYPE)) { typeInsn(Opcodes.CHECKCAST, type); } }