private static CompiledLambda defineLambdaMethod( RowExpressionCompiler innerExpressionCompiler, ClassDefinition classDefinition, String methodName, List<Parameter> inputParameters, LambdaDefinitionExpression lambda) { checkCondition(inputParameters.size() <= 254, NOT_SUPPORTED, "Too many arguments for lambda expression"); Class<?> returnType = Primitives.wrap(lambda.getBody().getType().getJavaType()); MethodDefinition method = classDefinition.declareMethod(a(PUBLIC), methodName, type(returnType), inputParameters); Scope scope = method.getScope(); Variable wasNull = scope.declareVariable(boolean.class, "wasNull"); BytecodeNode compiledBody = innerExpressionCompiler.compile(lambda.getBody(), scope, Optional.empty()); method.getBody() .putVariable(wasNull, false) .append(compiledBody) .append(boxPrimitiveIfNecessary(scope, returnType)) .ret(returnType); Handle lambdaAsmHandle = new Handle( Opcodes.H_INVOKEVIRTUAL, method.getThis().getType().getClassName(), method.getName(), method.getMethodDescriptor(), false); return new CompiledLambda( lambdaAsmHandle, method.getReturnType(), method.getParameterTypes()); }
public String getName() { return type.getClassName(); }
public TryCatch(String comment, BytecodeNode tryNode, BytecodeNode catchNode, ParameterizedType exceptionType) { this.comment = comment; this.tryNode = requireNonNull(tryNode, "tryNode is null"); this.catchNode = requireNonNull(catchNode, "catchNode is null"); this.exceptionName = (exceptionType != null) ? exceptionType.getClassName() : null; }
public IncrementVariableInstruction(Variable variable, byte increment) { super(variable); String type = variable.getType().getClassName(); Preconditions.checkArgument(ImmutableList.of("byte", "short", "int").contains(type), "variable must be an byte, short or int, but is %s", type); this.increment = increment; }
public BytecodeBlock incrementVariable(Variable variable, byte increment) { String type = variable.getType().getClassName(); checkArgument(ImmutableList.of("byte", "short", "int").contains(type), "variable must be an byte, short or int, but is %s", type); nodes.add(VariableInstruction.incrementVariable(variable, increment)); return this; }
@Override public void accept(MethodVisitor visitor, MethodGenerationContext generationContext) { visitor.visitFieldInsn(opCode.getOpCode(), classType.getClassName(), fieldName, fieldType.getType()); }
@Override public void accept(MethodVisitor visitor, MethodGenerationContext generationContext) { visitor.visitMethodInsn(opCode.getOpCode(), target.getClassName(), name, getMethodDescription(), target.isInterface()); }
@Override public void accept(MethodVisitor visitor, MethodGenerationContext generationContext) { Handle bootstrapMethodHandle = new Handle(Opcodes.H_INVOKESTATIC, type(bootstrapMethod.getDeclaringClass()).getClassName(), bootstrapMethod.getName(), methodDescription( bootstrapMethod.getReturnType(), bootstrapMethod.getParameterTypes()), false); visitor.visitInvokeDynamicInsn(getName(), getMethodDescription(), bootstrapMethodHandle, bootstrapArguments.toArray(new Object[bootstrapArguments.size()])); }
@Override public void accept(MethodVisitor visitor, MethodGenerationContext generationContext) { if (opCode == NEWARRAY) { checkState(type.isPrimitive(), "need primitive type for NEWARRAY"); visitor.visitIntInsn(opCode.getOpCode(), getPrimitiveArrayType(type)); } else { visitor.visitTypeInsn(opCode.getOpCode(), type.getClassName()); } }
interfaces[i] = this.interfaces.get(i).getClassName(); visitor.visit(V1_8, isInterface() ? accessModifier : accessModifier | ACC_SUPER, type.getClassName(), signature, superClass.getClassName(), interfaces);
String name = typeFromJavaClassName(className).getClassName() + ".class"; Path file = path.resolve(name).toAbsolutePath(); try {
exceptions[i] = this.exceptions.get(i).getClassName();
String classFileName = type.getClassName() + ".class"; try (InputStream is = classLoader.getResourceAsStream(classFileName)) { classReader = new ClassReader(is);
visitor.visitEnum(name, type(enumConstant.getDeclaringClass()).getClassName(), enumConstant.name());
toCodecType(metadata).getClassName(), type(Object.class), type(ThriftCodec.class, structType));
@Override protected String getCommonSuperClass(String aType, String bType) { ClassInfo aClassInfo = classInfoLoader.loadClassInfo(typeFromPathName(aType)); ClassInfo bClassInfo = classInfoLoader.loadClassInfo(typeFromPathName(bType)); if (aClassInfo.isAssignableFrom(bClassInfo)) { return aType; } if (bClassInfo.isAssignableFrom(aClassInfo)) { return bType; } if (aClassInfo.isInterface() || bClassInfo.isInterface()) { return "java/lang/Object"; } else { do { aClassInfo = aClassInfo.getSuperclass(); } while (!aClassInfo.isAssignableFrom(bClassInfo)); return aClassInfo.getType().getClassName(); } } }
private static CompiledLambda defineLambdaMethod( RowExpressionCompiler innerExpressionCompiler, ClassDefinition classDefinition, String methodName, List<Parameter> inputParameters, LambdaDefinitionExpression lambda) { checkCondition(inputParameters.size() <= 254, NOT_SUPPORTED, "Too many arguments for lambda expression"); Class<?> returnType = Primitives.wrap(lambda.getBody().getType().getJavaType()); MethodDefinition method = classDefinition.declareMethod(a(PUBLIC), methodName, type(returnType), inputParameters); Scope scope = method.getScope(); Variable wasNull = scope.declareVariable(boolean.class, "wasNull"); BytecodeNode compiledBody = innerExpressionCompiler.compile(lambda.getBody(), scope); method.getBody() .putVariable(wasNull, false) .append(compiledBody) .append(boxPrimitiveIfNecessary(scope, returnType)) .ret(returnType); Handle lambdaAsmHandle = new Handle( Opcodes.H_INVOKEVIRTUAL, method.getThis().getType().getClassName(), method.getName(), method.getMethodDescriptor(), false); return new CompiledLambda( lambdaAsmHandle, method.getReturnType(), method.getParameterTypes()); }
private static CompiledLambda defineLambdaMethod( RowExpressionCompiler innerExpressionCompiler, ClassDefinition classDefinition, String methodName, List<Parameter> inputParameters, LambdaDefinitionExpression lambda) { checkCondition(inputParameters.size() <= 254, NOT_SUPPORTED, "Too many arguments for lambda expression"); Class<?> returnType = Primitives.wrap(lambda.getBody().getType().getJavaType()); MethodDefinition method = classDefinition.declareMethod(a(PUBLIC), methodName, type(returnType), inputParameters); Scope scope = method.getScope(); Variable wasNull = scope.declareVariable(boolean.class, "wasNull"); BytecodeNode compiledBody = innerExpressionCompiler.compile(lambda.getBody(), scope); method.getBody() .putVariable(wasNull, false) .append(compiledBody) .append(boxPrimitiveIfNecessary(scope, returnType)) .ret(returnType); Handle lambdaAsmHandle = new Handle( Opcodes.H_INVOKEVIRTUAL, method.getThis().getType().getClassName(), method.getName(), method.getMethodDescriptor(), false); return new CompiledLambda( lambdaAsmHandle, method.getReturnType(), method.getParameterTypes()); }