public static Class createClass(String className, ParserContext pCtx) throws ClassNotFoundException { ClassLoader classLoader = currentThread().getContextClassLoader(); Map<String, WeakReference<Class>> cache = CLASS_RESOLVER_CACHE.get(classLoader); if (cache == null) { CLASS_RESOLVER_CACHE.put(classLoader, cache = new WeakHashMap<String, WeakReference<Class>>(10)); } WeakReference<Class> ref; Class cls; if ((ref = cache.get(className)) != null && (cls = ref.get()) != null) { return cls; } else { try { cls = pCtx == null ? Class.forName(className, true, Thread.currentThread().getContextClassLoader()) : Class.forName(className, true, pCtx.getParserConfiguration().getClassLoader()); } catch (ClassNotFoundException e) { /** * Now try the system classloader. */ cls = forName(className, true, Thread.currentThread().getContextClassLoader()); } cache.put(className, new WeakReference<Class>(cls)); return cls; } }
try { return Class.forName(new String(expr, 0, cursor = last), true, pCtx != null ? pCtx.getParserConfiguration().getClassLoader() : currentThread().getContextClassLoader()); pCtx.getParserConfiguration().getClassLoader() : currentThread().getContextClassLoader()); String name = new String(expr, i + 1, expr.length - i - 1); try {
public Object getDirectValue(Object staticContext, VariableResolverFactory factory) { if (importInjectionRequired) { return execute(false, this, staticContext, new ClassImportResolverFactory(parserContext.getParserConfiguration(), factory)); } else { return execute(false, this, staticContext, factory); } }
public Object getValue(Object staticContext, VariableResolverFactory factory) { if (!optimized) setupOptimizers(); if (importInjectionRequired) { return execute(false, this, staticContext, new ClassImportResolverFactory(parserContext.getParserConfiguration(), factory)); } else { return execute(false, this, staticContext, factory); } }
for (Method m : c.getMethods()) { if (property.equals(m.getName())) { if (pCtx!=null&& pCtx.getParserConfiguration()!=null?pCtx.getParserConfiguration().isAllowNakedMethCall():MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL) { return m.invoke(ctx, EMPTY_OBJ_ARR); else if (pCtx!=null&& pCtx.getParserConfiguration()!=null?pCtx.getParserConfiguration().isAllowNakedMethCall():MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL) { return getMethod(ctx, property);
public static Object executeDebugger(CompiledExpression expression, Object ctx, VariableResolverFactory vars) { try { if (expression.isImportInjectionRequired()) { return execute(true, expression, ctx, new ClassImportResolverFactory(expression .getParserContext().getParserConfiguration(), vars)); } else { return execute(true, expression, ctx, vars); } } catch (EndWithValue e) { return e.getValue(); } }
Constructor<?> cns = Class.forName(typeDescr.getClassName(), true, pCtx.getParserConfiguration().getClassLoader()) .getConstructor(EMPTYCLS);
/** * This is such a horrible hack, but it's more performant than any other horrible hack I can think of * right now. * * @param expr * @param cursor * @param pCtx */ public static void checkForPossibleUnresolvedViolations(char[] expr, int cursor, ParserContext pCtx) { if (isUnresolvedWaiting()) { LinkedHashMap<String, Object> imports = (LinkedHashMap<String, Object>) pCtx.getParserConfiguration().getImports(); Object o = imports.values().toArray()[imports.size() - 1]; if (o instanceof Proto) { Proto proto = (Proto) o; int last = proto.getCursorEnd(); cursor--; /** * We walk backwards to ensure that the last valid statement was a proto declaration. */ while (cursor > last && ParseTools.isWhitespace(expr[cursor])) cursor--; while (cursor > last && ParseTools.isIdentifierPart(expr[cursor])) cursor--; while (cursor > last && (ParseTools.isWhitespace(expr[cursor]) || expr[cursor] == ';')) cursor--; if (cursor != last) { throw new CompileException("unresolved reference (possible illegal forward-reference?): " + ProtoParser.getNextUnresolvedWaiting(), expr, proto.getCursorStart()); } } } }
/** * This is such a horrible hack, but it's more performant than any other horrible hack I can think of * right now. * * @param expr * @param cursor * @param pCtx */ public static void checkForPossibleUnresolvedViolations(char[] expr, int cursor, ParserContext pCtx) { if (isUnresolvedWaiting()) { LinkedHashMap<String, Object> imports = (LinkedHashMap<String, Object>) pCtx.getParserConfiguration().getImports(); Object o = imports.values().toArray()[imports.size() - 1]; if (o instanceof Proto) { Proto proto = (Proto) o; int last = proto.getCursorEnd(); cursor--; /** * We walk backwards to ensure that the last valid statement was a proto declaration. */ while (cursor > last && ParseTools.isWhitespace(expr[cursor])) cursor--; while (cursor > last && ParseTools.isIdentifierPart(expr[cursor])) cursor--; while (cursor > last && (ParseTools.isWhitespace(expr[cursor]) || expr[cursor] == ';')) cursor--; if (cursor != last) { throw new CompileException("unresolved reference (possible illegal forward-reference?): " + ProtoParser.getNextUnresolvedWaiting(), expr, proto.getCursorStart()); } } } }
Constructor<?> cns = Class.forName(typeDescr.getClassName(), true, pCtx.getParserConfiguration().getClassLoader()) .getConstructor(EMPTYCLS);
/** * This is such a horrible hack, but it's more performant than any other horrible hack I can think of * right now. * * @param expr * @param cursor * @param pCtx */ public static void checkForPossibleUnresolvedViolations(char[] expr, int cursor, ParserContext pCtx) { if (isUnresolvedWaiting()) { LinkedHashMap<String, Object> imports = (LinkedHashMap<String, Object>) pCtx.getParserConfiguration().getImports(); Object o = imports.values().toArray()[imports.size() - 1]; if (o instanceof Proto) { Proto proto = (Proto) o; int last = proto.getCursorEnd(); cursor--; /** * We walk backwards to ensure that the last valid statement was a proto declaration. */ while (cursor > last && ParseTools.isWhitespace(expr[cursor])) cursor--; while (cursor > last && ParseTools.isIdentifierPart(expr[cursor])) cursor--; while (cursor > last && (ParseTools.isWhitespace(expr[cursor]) || expr[cursor] == ';')) cursor--; if (cursor != last) { throw new CompileException("unresolved reference (possible illegal forward-reference?): " + ProtoParser.getNextUnresolvedWaiting(), expr, proto.getCursorStart()); } } } }
if (pCtx!=null&& pCtx.getParserConfiguration()!=null?pCtx.getParserConfiguration().isAllowNakedMethCall():MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL) { Class cls = getMethod(ctx, property); if (cls != Object.class) {
ParserContext ctx = new ParserContext(pCtx.getParserConfiguration()); ctx.setIndexAllocation(true);
ParserContext ctx = new ParserContext(pCtx.getParserConfiguration(), pCtx, true);
ParserContext ctx = new ParserContext(pCtx.getParserConfiguration(), pCtx, true);
pCtx.getParserConfiguration().setAllImports(getInjectedImports(factory));
if (pCtx == null) { pCtx = new ParserContext(); pCtx.getParserConfiguration().setAllImports(getInjectedImports(factory));
if (pCtx == null) { pCtx = new ParserContext(); pCtx.getParserConfiguration().setAllImports(getInjectedImports(factory));
if (node.getEgressType() == Class.class) { Class<?> classLiteral = pCtx.getParserConfiguration().getImport(variableName); if (classLiteral != null) { return new FixedExpression(Class.class, classLiteral);
context = new ParserContext(context.getParserConfiguration()); compiler = new ExpressionCompiler(text, context); execution = compiler.compile();