cbe.setClassName( def.getClassName() );
private static Function1<DataContext, Object[]> compile(String code, Object reason) { try { final ClassBodyEvaluator cbe = new ClassBodyEvaluator(); cbe.setClassName(GENERATED_CLASS_NAME); cbe.setExtendedClass(Utilities.class); cbe.setImplementedInterfaces(new Class[] {Function1.class, Serializable.class}); cbe.setParentClassLoader(RexExecutable.class.getClassLoader()); cbe.cook(new Scanner(null, new StringReader(code))); Class c = cbe.getClazz(); //noinspection unchecked final Constructor<Function1<DataContext, Object[]>> constructor = c.getConstructor(); return constructor.newInstance(); } catch (CompileException | IOException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new RuntimeException("While compiling " + reason, e); } }
private static Function1<DataContext, Object[]> compile(String code, Object reason) { try { final ClassBodyEvaluator cbe = new ClassBodyEvaluator(); cbe.setClassName(GENERATED_CLASS_NAME); cbe.setExtendedClass(Utilities.class); cbe.setImplementedInterfaces(new Class[] {Function1.class, Serializable.class}); cbe.setParentClassLoader(RexExecutable.class.getClassLoader()); cbe.cook(new Scanner(null, new StringReader(code))); Class c = cbe.getClazz(); //noinspection unchecked final Constructor<Function1<DataContext, Object[]>> constructor = c.getConstructor(); return constructor.newInstance(); } catch (CompileException | IOException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new RuntimeException("While compiling " + reason, e); } }