public static Method asmMethodSignatureToReflectionMethod(MethodSignature m) throws ClassNotFoundException, NoSuchMethodException { Class<?> reflectedClass = Class.forName(m.getOwnerType().getClassName()); Type []argTypes = Type.getMethodType(m.desc).getArgumentTypes(); Class<?> []argClasses = new Class[argTypes.length]; for (int n = 0; n < argTypes.length; n++) argClasses[n] = asmTypeToClass(argTypes[n]); return reflectedClass.getMethod(m.name, argClasses); }
protected ColumnExpressions<?> getAndValidateArg(int argIndex, Type argType) throws TypedValueVisitorException { // Currently, we only support parameters of a few small simple types. // We should also support more complex types (e.g. entities) and allow // fields/methods of those entities to be called in the query (code // motion will be used to push those field accesses or method calls // outside the query where they will be evaluated and then passed in // as a parameter) try { if (!ALLOWED_QUERY_PARAMETER_TYPES.contains(argType) && (Annotations.asmTypeToClass(argType).isPrimitive() || (!metamodel.isKnownEnumType(argType.getInternalName()) && !metamodel.isKnownManagedType(argType.getClassName()) && !metamodel.isKnownConvertedType(argType.getClassName())))) throw new TypedValueVisitorException("Accessing a field with unhandled type: " + Annotations.asmTypeToClass(argType).getName()); } catch (ClassNotFoundException e) { throw new TypedValueVisitorException("Accessing a field with unhandled type", e); } return ColumnExpressions.singleColumn(new SimpleRowReader<>(), new ParameterExpression(lambda.getLambdaIndex(), argIndex)); }
protected JPQLQuery<?> getAndValidateSubQueryArg(int argIndex, Type argType) throws TypedValueVisitorException { // There are a few cases where collections can be passed into a query. try { if (!Collection.class.isAssignableFrom(Annotations.asmTypeToClass(argType))) { throw new TypedValueVisitorException("Using an unhandled type as a subquery parameter"); } } catch (ClassNotFoundException e) { throw new TypedValueVisitorException("Cannot find the class of the object being used as a parameter."); } ParameterAsQuery<?> query = new ParameterAsQuery<>(); query.cols = ColumnExpressions.singleColumn(new SimpleRowReader<>(), new ParameterExpression(lambda.getLambdaIndex(), argIndex)); return query; }
&& (Annotations.asmTypeToClass(argType).isPrimitive() || (!metamodel.isKnownEnumType(argType.getInternalName()) && !metamodel.isKnownManagedType(argType.getClassName()) && !metamodel.isKnownConvertedType(argType.getClassName())))) throw new TypedValueVisitorException("Accessing a field with unhandled type: " + Annotations.asmTypeToClass(argType).getName());