@Override public JExpression injectMagic(final TreeLogger logger, final JMethodCall callSite, final JMethod enclosingMethod, final Context context, final UnifyAstView ast) throws UnableToCompleteException { final boolean isFromGwtReflect = callSite.getArgs().size() == 2; final JExpression inst = isFromGwtReflect ? callSite.getArgs().get(0) : callSite.getInstance(); final JClassLiteral classLit = ReflectionUtilAst.extractClassLiteral(logger, inst, ast, false); final List<JExpression> args = callSite.getArgs(); final JExpression arg0 = args.get(isFromGwtReflect?1:0); // and return a call to the generated Method provider return getFactoryMethod(logger, callSite, enclosingMethod, context, classLit, inst, arg0, ast) .makeStatement().getExpr(); }
@Override public JExpression injectMagic(TreeLogger logger, JMethodCall callSite, JMethod enclosingMethod, Context context, UnifyAstView ast) throws UnableToCompleteException { boolean isFromGwtReflect = callSite.getArgs().size() == 2; JExpression inst = isFromGwtReflect ? callSite.getArgs().get(0) : callSite.getInstance(); JClassLiteral classLit = ReflectionUtilAst.extractClassLiteral(logger, inst, ast, false); List<JExpression> args = callSite.getArgs(); JExpression arg0 = args.get(isFromGwtReflect?1:0); // and return a call to the generated Method provider return getFactoryMethod(logger, callSite, enclosingMethod, context, classLit, inst, arg0, ast) .makeStatement().getExpr(); }
/** * Implements a caching layer guarding the {@link #initialize(String, ReflectionGeneratorContext)} method * * @param key * @param params * @return */ protected JExpression get(String key, ReflectionGeneratorContext params) { //because we cache results, super dev mode recompiles need to skip the //cache if the magic class does not exist, thus we test type presence on every get(). JDeclaredType type = params.getAst().searchForTypeByBinary(params.getClazz().getRefType().getName()); String typeName = JGwtCreate.nameOf(type); String generatedName = ReflectionUtilJava.generatedMagicClassName(typeName); try { params.getAst().searchForTypeBySource(generatedName); }catch(NoClassDefFoundError e) { classEnhancers.remove(key); } if (classEnhancers.containsKey(key)) { JMethodCall previous = classEnhancers.get(key); previous = new JMethodCall(previous, previous.getInstance()); previous.addArg(params.getClazz().makeStatement().getExpr()); return previous.makeStatement().getExpr(); } JMethodCall expr = initialize(key, params); classEnhancers.put(key, expr); expr.setArg(0, params.getClazz().makeStatement().getExpr()); return expr.makeStatement().getExpr(); }
final boolean isDebug = logger.isLoggable(logLevel()); final boolean isFromGwtReflect = callSite.getArgs().size() > 1; final JExpression inst = isFromGwtReflect ? callSite.getArgs().get(0) : callSite.getInstance(); logger.log(logLevel(), "Non-final class literal used to invoke constructor via reflection; " + ReflectionUtilAst.debug(callSite.getInstance()));
final boolean isDebug = logger.isLoggable(logLevel()); final boolean isFromGwtReflect = callSite.getArgs().size() > 1; final JExpression inst = isFromGwtReflect ? callSite.getArgs().get(0) : callSite.getInstance(); logger.log(logLevel(), "Non-final class literal used to invoke constructor via reflection; " + ReflectionUtilAst.debug(callSite.getInstance())); return checkConstPool(ast, callSite, inst, arg0);
/** * Implements a caching layer guarding the {@link #initialize(String, ReflectionGeneratorContext)} method * * @param key * @param params * @return * @throws UnableToCompleteException */ protected JExpression get(final String key, final ReflectionGeneratorContext params) throws UnableToCompleteException { //because we cache results, super dev mode recompiles need to skip the //cache if the magic class does not exist, thus we test type presence on every get(). final JDeclaredType type = params.getAst().searchForTypeByBinary(params.getClazz().getRefType().getName()); final String typeName = BinaryName.toSourceName(type.getName()); final String generatedName = ReflectionUtilJava.generatedMagicClassName(typeName); if (null == params.getAst().searchForTypeBySource(generatedName)) { classEnhancers.remove(key); } if (classEnhancers.containsKey(key)) { JMethodCall previous = classEnhancers.get(key); previous = new JMethodCall(previous, previous.getInstance()); previous.addArg(params.getClazz().makeStatement().getExpr()); return previous.makeStatement().getExpr(); } final JMethodCall expr = initialize(key, params); classEnhancers.put(key, expr); expr.setArg(0, params.getClazz().makeStatement().getExpr()); return expr.makeStatement().getExpr(); }
final boolean isDebug = logger.isLoggable(logLevel()); final boolean isFromGwtReflect = callSite.getArgs().size() > 2; final JExpression inst = isFromGwtReflect ? callSite.getArgs().get(0) : callSite.getInstance(); logger.log(logLevel(), "Non-final class literal used to invoke reflection method; " + ReflectionUtilAst.debug(callSite.getInstance())); return checkConstPool(ast, callSite, inst, arg0, arg1);
final boolean isDebug = logger.isLoggable(logLevel()); final boolean isFromGwtReflect = callSite.getArgs().size() > 2; final JExpression inst = isFromGwtReflect ? callSite.getArgs().get(0) : callSite.getInstance(); logger.log(logLevel(), "Non-final class literal used to invoke reflection method; " + ReflectionUtilAst.debug(callSite.getInstance()));
final boolean isDebug = logger.isLoggable(logLevel()); final boolean isFromGwtReflect = callSite.getArgs().size() > 1; final JExpression inst = isFromGwtReflect ? callSite.getArgs().get(0) : callSite.getInstance(); final JExpression annoParam = callSite.getArgs().get(isFromGwtReflect ? 1 : 0);
logger.log(logLevel(), "Non-final class literal used to invoke reflection field; " + ReflectionUtilAst.debug(callSite.getInstance())); return checkConstPool(ast, callSite, inst, arg0);
logger.log(logLevel(), "Non-final class literal used to invoke reflection field; " + ReflectionUtilAst.debug(callSite.getInstance()));