/** * Attempt compilation of the supplied expression. A check is made to see * if it is compilable before compilation proceeds. The check involves * visiting all the nodes in the expression Ast and ensuring enough state * is known about them that bytecode can be generated for them. * @param expression the expression to compile * @return an instance of the class implementing the compiled expression, * or {@code null} if compilation is not possible */ @Nullable public CompiledExpression compile(SpelNodeImpl expression) { if (expression.isCompilable()) { if (logger.isDebugEnabled()) { logger.debug("SpEL: compiling " + expression.toStringAST()); } Class<? extends CompiledExpression> clazz = createExpressionClass(expression); if (clazz != null) { try { return ReflectionUtils.accessibleConstructor(clazz).newInstance(); } catch (Throwable ex) { throw new IllegalStateException("Failed to instantiate CompiledExpression", ex); } } } if (logger.isDebugEnabled()) { logger.debug("SpEL: unable to compile " + expression.toStringAST()); } return null; }
/** * Attempt compilation of the supplied expression. A check is made to see * if it is compilable before compilation proceeds. The check involves * visiting all the nodes in the expression Ast and ensuring enough state * is known about them that bytecode can be generated for them. * @param expression the expression to compile * @return an instance of the class implementing the compiled expression, * or {@code null} if compilation is not possible */ @Nullable public CompiledExpression compile(SpelNodeImpl expression) { if (expression.isCompilable()) { if (logger.isDebugEnabled()) { logger.debug("SpEL: compiling " + expression.toStringAST()); } Class<? extends CompiledExpression> clazz = createExpressionClass(expression); if (clazz != null) { try { return ReflectionUtils.accessibleConstructor(clazz).newInstance(); } catch (Throwable ex) { throw new IllegalStateException("Failed to instantiate CompiledExpression", ex); } } } if (logger.isDebugEnabled()) { logger.debug("SpEL: unable to compile " + expression.toStringAST()); } return null; }
/** * Attempt compilation of the supplied expression. A check is made to see * if it is compilable before compilation proceeds. The check involves * visiting all the nodes in the expression Ast and ensuring enough state * is known about them that bytecode can be generated for them. * @param expression the expression to compile * @return an instance of the class implementing the compiled expression, * or {@code null} if compilation is not possible */ @Nullable public CompiledExpression compile(SpelNodeImpl expression) { if (expression.isCompilable()) { if (logger.isDebugEnabled()) { logger.debug("SpEL: compiling " + expression.toStringAST()); } Class<? extends CompiledExpression> clazz = createExpressionClass(expression); if (clazz != null) { try { return ReflectionUtils.accessibleConstructor(clazz).newInstance(); } catch (Throwable ex) { throw new IllegalStateException("Failed to instantiate CompiledExpression", ex); } } } if (logger.isDebugEnabled()) { logger.debug("SpEL: unable to compile " + expression.toStringAST()); } return null; }