From 2f84ac1cae49669d60f9b951ab3e7406c4d6ed33 Mon Sep 17 00:00:00 2001 From: michaeloffner Date: Tue, 17 Dec 2024 23:28:40 +0100 Subject: [PATCH] expose argument nameCaseSensitive in all methods and use more direct approach in VariablesUtil (minor change) --- .../lucee/commons/io/TemporaryStream.java | 2 + .../io/log/log4j2/layout/DataDogLayout.java | 4 +- .../commons/io/res/util/ResourceUtil.java | 2 +- .../java/lucee/commons/sql/OracleBlob.java | 6 +- .../java/lucee/commons/sql/OracleClob.java | 6 +- .../java/lucee/runtime/cache/CacheUtil.java | 4 +- .../runtime/cfx/customtag/CPPCustomTag.java | 2 +- .../lucee/runtime/config/ConfigAdmin.java | 2 +- .../runtime/config/ConfigWebFactory.java | 2 +- .../java/lucee/runtime/java/JavaObject.java | 8 +- .../lucee/runtime/reflection/Reflector.java | 149 +++++++++------- .../reflection/pairs/ConstructorInstance.java | 3 +- .../reflection/pairs/MethodInstance.java | 34 ++-- .../main/java/lucee/runtime/tag/TagUtil.java | 2 +- .../lucee/runtime/type/QueryColumnImpl.java | 2 +- .../lucee/runtime/type/util/MemberUtil.java | 2 +- .../lucee/runtime/util/ClassUtilImpl.java | 8 +- .../lucee/runtime/util/VariableUtilImpl.java | 13 +- .../transformer/dynamic/DynamicInvoker.java | 165 +++++++++++------- .../lucee/transformer/dynamic/meta/Clazz.java | 13 +- .../dynamic/meta/FunctionMember.java | 6 + .../transformer/dynamic/meta/Method.java | 7 - .../dynamic/meta/dynamic/ClazzDynamic.java | 49 +++--- .../dynamic/meta/dynamic/MethodDynamic.java | 4 +- .../reflection/ConstructorReflection.java | 17 ++ loader/build.xml | 2 +- loader/pom.xml | 2 +- 27 files changed, 306 insertions(+), 210 deletions(-) diff --git a/core/src/main/java/lucee/commons/io/TemporaryStream.java b/core/src/main/java/lucee/commons/io/TemporaryStream.java index 904524e7cc..1d931be2ae 100644 --- a/core/src/main/java/lucee/commons/io/TemporaryStream.java +++ b/core/src/main/java/lucee/commons/io/TemporaryStream.java @@ -24,6 +24,7 @@ import java.io.InputStream; import java.io.OutputStream; +import lucee.commons.io.log.LogUtil; import lucee.commons.io.res.Resource; import lucee.commons.io.res.util.ResourceUtil; import lucee.commons.lang.SerializableObject; @@ -197,6 +198,7 @@ public static Resource getTempDirectory() { tempFile = getCanonicalResourceEL(tempFile); } catch (IOException ioe) { + LogUtil.warn("temporary-stream", ioe); } finally { if (tmp != null) tmp.delete(); diff --git a/core/src/main/java/lucee/commons/io/log/log4j2/layout/DataDogLayout.java b/core/src/main/java/lucee/commons/io/log/log4j2/layout/DataDogLayout.java index 85677c4ce7..320ccaa554 100644 --- a/core/src/main/java/lucee/commons/io/log/log4j2/layout/DataDogLayout.java +++ b/core/src/main/java/lucee/commons/io/log/log4j2/layout/DataDogLayout.java @@ -187,12 +187,12 @@ private static Object[] getCorrelationIdentifier() { // CorrelationIdentifier.getTraceId() if (getTraceId == null) { - getTraceId = Reflector.getMethod(correlationIdentifierClass, "getTraceId", EMPTY_CLASS); + getTraceId = Reflector.getMethod(correlationIdentifierClass, "getTraceId", EMPTY_CLASS, true); } // CorrelationIdentifier.getSpanId() if (getSpanId == null) { - getSpanId = Reflector.getMethod(correlationIdentifierClass, "getSpanId", EMPTY_CLASS); + getSpanId = Reflector.getMethod(correlationIdentifierClass, "getSpanId", EMPTY_CLASS, true); } Object[] tmp = new Object[] { getTraceId.invoke(null, EMPTY_OBJ), getSpanId.invoke(null, EMPTY_OBJ) }; diff --git a/core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java b/core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java index 99edb2d36a..cb9b533acf 100755 --- a/core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java +++ b/core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java @@ -978,7 +978,7 @@ public static void _deleteContent(Resource src, ResourceFilter filter, boolean d src.remove(false); } catch (IOException e) { - LogUtil.warn("resource", e); + // LogUtil.warn("resource", e); } } } diff --git a/core/src/main/java/lucee/commons/sql/OracleBlob.java b/core/src/main/java/lucee/commons/sql/OracleBlob.java index 59d037dea8..c9aa6deaff 100644 --- a/core/src/main/java/lucee/commons/sql/OracleBlob.java +++ b/core/src/main/java/lucee/commons/sql/OracleBlob.java @@ -46,19 +46,19 @@ public static Blob createBlob(Connection conn, byte[] barr, Blob defaultValue) { // BLOB blob = BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION); if (createTemporary == null || createTemporary.getDeclaringClass() != clazz) { - createTemporary = Reflector.getMethod(clazz, "createTemporary", new Class[] { Connection.class, boolean.class, int.class }); + createTemporary = Reflector.getMethod(clazz, "createTemporary", new Class[] { Connection.class, boolean.class, int.class }, true); } Object blob = createTemporary.invoke(null, new Object[] { conn, Boolean.FALSE, duration }); // blob.open(BLOB.MODE_READWRITE); if (open == null || open.getDeclaringClass() != clazz) { - open = Reflector.getMethod(clazz, "open", new Class[] { int.class }); + open = Reflector.getMethod(clazz, "open", new Class[] { int.class }, true); } open.invoke(blob, new Object[] { mode }); // blob.setBytes(1,barr); if (setBytes == null || setBytes.getDeclaringClass() != clazz) { - setBytes = Reflector.getMethod(clazz, "setBytes", new Class[] { long.class, byte[].class }); + setBytes = Reflector.getMethod(clazz, "setBytes", new Class[] { long.class, byte[].class }, true); } setBytes.invoke(blob, new Object[] { Long.valueOf(1), barr }); diff --git a/core/src/main/java/lucee/commons/sql/OracleClob.java b/core/src/main/java/lucee/commons/sql/OracleClob.java index 4fdf5c2277..be9078e8b1 100644 --- a/core/src/main/java/lucee/commons/sql/OracleClob.java +++ b/core/src/main/java/lucee/commons/sql/OracleClob.java @@ -46,19 +46,19 @@ public static Clob createClob(Connection conn, String value, Clob defaultValue) // CLOB c = CLOB.createTemporary(conn, false, CLOB.DURATION_SESSION); if (createTemporary == null || createTemporary.getDeclaringClass() != clazz) { - createTemporary = Reflector.getMethod(clazz, "createTemporary", new Class[] { Connection.class, boolean.class, int.class }); + createTemporary = Reflector.getMethod(clazz, "createTemporary", new Class[] { Connection.class, boolean.class, int.class }, true); } Object clob = createTemporary.invoke(null, new Object[] { conn, Boolean.FALSE, duration }); // c.open(CLOB.MODE_READWRITE); if (open == null || open.getDeclaringClass() != clazz) { - open = Reflector.getMethod(clazz, "open", new Class[] { int.class }); + open = Reflector.getMethod(clazz, "open", new Class[] { int.class }, true); } open.invoke(clob, new Object[] { mode }); // c.setString(1,value); if (setString == null || setString.getDeclaringClass() != clazz) { - setString = Reflector.getMethod(clazz, "setString", new Class[] { long.class, String.class }); + setString = Reflector.getMethod(clazz, "setString", new Class[] { long.class, String.class }, true); } setString.invoke(clob, new Object[] { Long.valueOf(1), value }); diff --git a/core/src/main/java/lucee/runtime/cache/CacheUtil.java b/core/src/main/java/lucee/runtime/cache/CacheUtil.java index 6b32e75aea..f0899041f9 100644 --- a/core/src/main/java/lucee/runtime/cache/CacheUtil.java +++ b/core/src/main/java/lucee/runtime/cache/CacheUtil.java @@ -268,7 +268,7 @@ public static void remove(ConfigWeb config, CacheConnection cc) throws Throwable Cache c = cc.getInstance(config); // FUTURE no reflection needed Object[] empty = new Object[0]; - MethodInstance remove = Reflector.getMethodInstance(c.getClass(), KeyImpl.init("remove"), empty, true); + MethodInstance remove = Reflector.getMethodInstance(c.getClass(), KeyImpl.init("remove"), empty, true, true); if (!remove.hasMethod()) { c.remove((CacheEntryFilter) null); return; @@ -291,7 +291,7 @@ public static void release(CacheConnection cc) throws IOException { // FUTURE no reflection needed Object[] empty = new Object[0]; - MethodInstance release = Reflector.getMethodInstance(c.getClass(), KeyImpl.init("release"), empty, true); + MethodInstance release = Reflector.getMethodInstance(c.getClass(), KeyImpl.init("release"), empty, true, true); if (!release.hasMethod()) { return; } diff --git a/core/src/main/java/lucee/runtime/cfx/customtag/CPPCustomTag.java b/core/src/main/java/lucee/runtime/cfx/customtag/CPPCustomTag.java index 898b81fd76..0b6662b590 100755 --- a/core/src/main/java/lucee/runtime/cfx/customtag/CPPCustomTag.java +++ b/core/src/main/java/lucee/runtime/cfx/customtag/CPPCustomTag.java @@ -53,7 +53,7 @@ public CPPCustomTag(String serverLibrary, String procedure, boolean keepAlive) t } try { - processRequest = Reflector.getMethod(clazz, "processRequest", new Class[] { String.class, String.class, Request.class, Response.class, boolean.class }); + processRequest = Reflector.getMethod(clazz, "processRequest", new Class[] { String.class, String.class, Request.class, Response.class, boolean.class }, true); } catch (Exception e) { throw new CFXTagException(e); diff --git a/core/src/main/java/lucee/runtime/config/ConfigAdmin.java b/core/src/main/java/lucee/runtime/config/ConfigAdmin.java index 8a06139b47..db3a0daaa7 100755 --- a/core/src/main/java/lucee/runtime/config/ConfigAdmin.java +++ b/core/src/main/java/lucee/runtime/config/ConfigAdmin.java @@ -1689,7 +1689,7 @@ private void unloadStartupIfNecessary(ConfigPro config, ClassDefinition cd, b if (startup.cd.equals(cd) && !force) return; try { - lucee.transformer.dynamic.meta.Method fin = Reflector.getMethod(startup.instance.getClass(), "finalize", new Class[0], null); + lucee.transformer.dynamic.meta.Method fin = Reflector.getMethod(startup.instance.getClass(), "finalize", new Class[0], true, null); if (fin != null) { fin.invoke(startup.instance, new Object[0]); } diff --git a/core/src/main/java/lucee/runtime/config/ConfigWebFactory.java b/core/src/main/java/lucee/runtime/config/ConfigWebFactory.java index ed94ecee54..f480a3008c 100644 --- a/core/src/main/java/lucee/runtime/config/ConfigWebFactory.java +++ b/core/src/main/java/lucee/runtime/config/ConfigWebFactory.java @@ -4472,7 +4472,7 @@ private static void _loadStartupHook(ConfigServerImpl configServer, ConfigImpl c if (existing != null) { if (existing.cd.equals(cd)) continue; try { - Method fin = Reflector.getMethod(existing.instance.getClass(), "finalize", new Class[0], null); + Method fin = Reflector.getMethod(existing.instance.getClass(), "finalize", new Class[0], true, null); if (fin != null) { fin.invoke(existing.instance, new Object[0]); } diff --git a/core/src/main/java/lucee/runtime/java/JavaObject.java b/core/src/main/java/lucee/runtime/java/JavaObject.java index 59e6fba5e9..0e71e446d8 100644 --- a/core/src/main/java/lucee/runtime/java/JavaObject.java +++ b/core/src/main/java/lucee/runtime/java/JavaObject.java @@ -95,7 +95,7 @@ public Object get(PageContext pc, String propertyName) throws PageException { } } // Getter - MethodInstance mi = Reflector.getGetterEL(clazz, propertyName); + MethodInstance mi = Reflector.getGetterEL(clazz, propertyName, false); if (mi != null) { if (mi.getMethod().isStatic()) { try { @@ -136,7 +136,7 @@ public Object get(PageContext pc, String propertyName, Object defaultValue) { } } // Getter - MethodInstance mi = Reflector.getGetterEL(clazz, propertyName); + MethodInstance mi = Reflector.getGetterEL(clazz, propertyName, false); if (mi != null) { try { if (mi.getMethod().isStatic()) { @@ -250,13 +250,13 @@ else if (methodName.equalsIgnoreCase("getClass")) { return clazz; } else if (isInit) { - return Reflector.callMethod(object, methodName, arguments); + return Reflector.callMethod(object, methodName, arguments, false); } try { // get method // if ("toHexString".equals(methodName)) print.ds(); - MethodInstance mi = Reflector.getMethodInstance(clazz, KeyImpl.init(methodName), arguments, false); + MethodInstance mi = Reflector.getMethodInstance(clazz, KeyImpl.init(methodName), arguments, false, false); // call static method if exist if (mi.getMethod().isStatic()) { return mi.invoke(null); diff --git a/core/src/main/java/lucee/runtime/reflection/Reflector.java b/core/src/main/java/lucee/runtime/reflection/Reflector.java index a57e895e54..8d135667ca 100755 --- a/core/src/main/java/lucee/runtime/reflection/Reflector.java +++ b/core/src/main/java/lucee/runtime/reflection/Reflector.java @@ -80,6 +80,7 @@ import lucee.transformer.dynamic.DynamicInvoker; import lucee.transformer.dynamic.meta.Clazz; import lucee.transformer.dynamic.meta.Constructor; +import lucee.transformer.dynamic.meta.FunctionMember; import lucee.transformer.dynamic.meta.Method; /** @@ -688,8 +689,12 @@ private static Object _clean(ObjectIdentityHashSet done, Collection coll) { return coll; } - public static MethodInstance getMethodInstance(Class clazz, final Collection.Key methodName, Object[] args, boolean exactMatchOnly) { - return new MethodInstance(clazz, methodName, args, !exactMatchOnly); + public static MethodInstance getMethodInstance(Class clazz, final FunctionMember fm, Object[] args, boolean nameCaseSensitive, boolean exactMatchOnly) { + return new MethodInstance(clazz, fm, args, nameCaseSensitive, !exactMatchOnly); + } + + public static MethodInstance getMethodInstance(Class clazz, final Collection.Key methodName, Object[] args, boolean nameCaseSensitive, boolean exactMatchOnly) { + return new MethodInstance(clazz, methodName, args, nameCaseSensitive, !exactMatchOnly); } public static String pos(int index) { @@ -852,31 +857,24 @@ public static Object callConstructor(Class clazz, Object[] args, Object defaultV * @throws PageException */ public static Object callMethod(Object obj, String methodName, Object[] args) throws PageException { - return callMethod(obj, KeyImpl.init(methodName), args); + return callMethod(obj, KeyImpl.init(methodName), args, false); } - public static Object callMethod(final Object obj, Collection.Key methodName, Object[] args) throws PageException { - if (obj == null) { - throw new ExpressionException("can't call method [" + methodName + "] on object, object is null"); - } + public static Object callMethod(Object obj, String methodName, Object[] args, boolean nameCaseSensitive) throws PageException { + return callMethod(obj, KeyImpl.init(methodName), args, nameCaseSensitive); + } - MethodInstance mi = getMethodInstance(obj.getClass(), methodName, args, false); - // if (!mi.hasMethod()) throw throwCall(obj, methodName.getString(), args); - try { - return mi.invoke(obj); - } - catch (Exception e) { - throw Caster.toPageException(e); - } + public static Object callMethod(final Object obj, Collection.Key methodName, Object[] args, boolean nameCaseSensitive) throws PageException { + return getMethodInstance(obj.getClass(), methodName, args, nameCaseSensitive, false).invoke(obj); } - public static boolean hasMethod(Class clazz, String methodName, Object[] args) { - MethodInstance mi = getMethodInstance(clazz, KeyImpl.init(methodName), args, false); + public static boolean hasMethod(Class clazz, String methodName, Object[] args, boolean nameCaseSensitive) { + MethodInstance mi = getMethodInstance(clazz, KeyImpl.init(methodName), args, nameCaseSensitive, false); return mi.hasMethod(); } - public static boolean hasMethod(Class clazz, Collection.Key methodName, Object[] args) { - MethodInstance mi = getMethodInstance(clazz, methodName, args, false); + public static boolean hasMethod(Class clazz, Collection.Key methodName, Object[] args, boolean nameCaseSensitive) { + MethodInstance mi = getMethodInstance(clazz, methodName, args, nameCaseSensitive, false); return mi.hasMethod(); } @@ -904,13 +902,13 @@ public static void checkAccessibility(Clazz clazz, Key methodName) { * )); } } } */ - public static Object callMethod(Object obj, Collection.Key methodName, Object[] args, Object defaultValue) { + public static Object callMethod(Object obj, Collection.Key methodName, Object[] args, boolean nameCaseSensitive, Object defaultValue) { if (obj == null) { return defaultValue; } // checkAccesibility(obj,methodName); - MethodInstance mi = getMethodInstance(obj.getClass(), methodName, args, false); + MethodInstance mi = getMethodInstance(obj.getClass(), methodName, args, nameCaseSensitive, false); if (!mi.hasMethod()) return defaultValue; try { return mi.invoke(obj); @@ -929,7 +927,11 @@ public static ExpressionException throwCall(Object obj, String methodName, Objec } public static Object callStaticMethod(Class clazz, String methodName, Object[] args) throws PageException { - return callStaticMethod(clazz, KeyImpl.init(methodName), args); + return callStaticMethod(clazz, KeyImpl.init(methodName), args, false); + } + + public static Object callStaticMethod(Class clazz, String methodName, Object[] args, boolean nameCaseSensitive) throws PageException { + return callStaticMethod(clazz, KeyImpl.init(methodName), args, nameCaseSensitive); } /** @@ -941,9 +943,19 @@ public static Object callStaticMethod(Class clazz, String methodName, Object[] a * @return return return value of the called Method * @throws PageException */ + public static Object callStaticMethod(Class clazz, Collection.Key methodName, Object[] args) throws PageException { try { - return getMethodInstance(clazz, methodName, args, false).invoke(null); + return getMethodInstance(clazz, methodName, args, false, false).invoke(null); + } + catch (Exception e) { + throw Caster.toPageException(e); + } + } + + public static Object callStaticMethod(Class clazz, Collection.Key methodName, Object[] args, boolean nameCaseSensitive) throws PageException { + try { + return getMethodInstance(clazz, methodName, args, nameCaseSensitive, false).invoke(null); } catch (Exception e) { throw Caster.toPageException(e); @@ -959,13 +971,14 @@ public static Object callStaticMethod(Class clazz, Collection.Key methodName, Ob * @throws NoSuchMethodException * @throws PageException */ - public static MethodInstance getGetter(Class clazz, String prop) throws PageException, NoSuchMethodException { + + public static MethodInstance getGetter(Class clazz, String prop, boolean nameCaseSensitive) throws PageException, NoSuchMethodException { String getterName = "get" + StringUtil.ucFirst(prop); - MethodInstance mi = getMethodInstance(clazz, KeyImpl.init(getterName), ArrayUtil.OBJECT_EMPTY, false); + MethodInstance mi = getMethodInstance(clazz, KeyImpl.init(getterName), ArrayUtil.OBJECT_EMPTY, nameCaseSensitive, false); if (!mi.hasMethod()) { String isName = "is" + StringUtil.ucFirst(prop); - mi = getMethodInstance(clazz, KeyImpl.init(isName), ArrayUtil.OBJECT_EMPTY, false); + mi = getMethodInstance(clazz, KeyImpl.init(isName), ArrayUtil.OBJECT_EMPTY, nameCaseSensitive, false); if (mi.hasMethod()) { lucee.transformer.dynamic.meta.Method m = mi.getMethod(); Class rtn = m.getReturnClass(); @@ -989,9 +1002,9 @@ public static MethodInstance getGetter(Class clazz, String prop) throws PageExce * @param prop Name of the Method without get * @return return Value of the getter Method */ - public static MethodInstance getGetterEL(Class clazz, String prop) { + public static MethodInstance getGetterEL(Class clazz, String prop, boolean nameCaseSensitive) { prop = "get" + StringUtil.ucFirst(prop); - MethodInstance mi = getMethodInstance(clazz, KeyImpl.init(prop), ArrayUtil.OBJECT_EMPTY, false); + MethodInstance mi = getMethodInstance(clazz, KeyImpl.init(prop), ArrayUtil.OBJECT_EMPTY, nameCaseSensitive, false); if (!mi.hasMethod()) return null; try { if (mi.getMethod().getReturnClass() == void.class) return null; @@ -1010,9 +1023,9 @@ public static MethodInstance getGetterEL(Class clazz, String prop) { * @return return Value of the getter Method * @throws PageException */ - public static Object callGetter(Object obj, String prop) throws PageException { + public static Object callGetter(Object obj, String prop, boolean nameCaseSensitive) throws PageException { try { - return getGetter(obj.getClass(), prop).invoke(obj); + return getGetter(obj.getClass(), prop, nameCaseSensitive).invoke(obj); } catch (Exception e) { throw Caster.toPageException(e); @@ -1032,9 +1045,9 @@ public static Object callGetter(Object obj, String prop) throws PageException { * @throws IOException * @throws ClassNotFoundException */ - public static MethodInstance getSetter(Object obj, String prop, Object value) throws PageException { + public static MethodInstance getSetter(Object obj, String prop, Object value, boolean nameCaseSensitive) throws PageException { prop = "set" + StringUtil.ucFirst(prop); - MethodInstance mi = getMethodInstance(obj.getClass(), KeyImpl.init(prop), new Object[] { value }, false); + MethodInstance mi = getMethodInstance(obj.getClass(), KeyImpl.init(prop), new Object[] { value }, nameCaseSensitive, false); lucee.transformer.dynamic.meta.Method m = mi.getMethod(); if (m.getReturnClass() != void.class) @@ -1051,8 +1064,12 @@ public static MethodInstance getSetter(Object obj, String prop, Object value) th * @return MethodInstance */ public static MethodInstance getSetter(Object obj, String prop, Object value, MethodInstance defaultValue) { + return getSetter(obj, prop, value, false, defaultValue); + } + + public static MethodInstance getSetter(Object obj, String prop, Object value, boolean nameCaseSensitive, MethodInstance defaultValue) { prop = "set" + StringUtil.ucFirst(prop); - MethodInstance mi = getMethodInstance(obj.getClass(), KeyImpl.init(prop), new Object[] { value }, false); + MethodInstance mi = getMethodInstance(obj.getClass(), KeyImpl.init(prop), new Object[] { value }, nameCaseSensitive, false); lucee.transformer.dynamic.meta.Method m; if ((m = mi.getMethod(null)) == null) return defaultValue; @@ -1070,7 +1087,16 @@ public static MethodInstance getSetter(Object obj, String prop, Object value, Me */ public static void callSetter(Object obj, String prop, Object value) throws PageException { try { - getSetter(obj, prop, value).invoke(obj); + getSetter(obj, prop, value, false).invoke(obj); + } + catch (Exception e) { + throw Caster.toPageException(e); + } + } + + public static void callSetter(Object obj, String prop, Object value, boolean nameCaseSensitive) throws PageException { + try { + getSetter(obj, prop, value, nameCaseSensitive).invoke(obj); } catch (Exception e) { throw Caster.toPageException(e); @@ -1085,9 +1111,9 @@ public static void callSetter(Object obj, String prop, Object value) throws Page * @param value * @throws PageException */ - public static void callSetterEL(Object obj, String prop, Object value) throws PageException { + public static void callSetterEL(Object obj, String prop, Object value, boolean nameCaseSensitive) throws PageException { try { - MethodInstance setter = getSetter(obj, prop, value, null); + MethodInstance setter = getSetter(obj, prop, value, nameCaseSensitive, null); if (setter != null) setter.invoke(obj); } catch (Exception e) { @@ -1182,20 +1208,15 @@ public static boolean setField(Object obj, String prop, Object value) throws Pag * @return property value * @throws PageException */ - public static Object getProperty(Object obj, String prop) throws PageException { + public static Object getProperty(Object obj, String prop, boolean nameCaseSensitive) throws PageException { Object rtn = getField(obj, prop, CollectionUtil.NULL);// NULL is used because the field can contain null as well if (rtn != CollectionUtil.NULL) return rtn; char first = prop.charAt(0); - MethodInstance getter = (first >= '0' && first <= '9') ? null : getGetterEL(obj.getClass(), prop); + MethodInstance getter = (first >= '0' && first <= '9') ? null : getGetterEL(obj.getClass(), prop, nameCaseSensitive); if (getter == null) throw new ApplicationException("there is no property with name [" + prop + "] found in [" + Caster.toTypeName(obj) + "]"); - try { - return getter.invoke(obj); - } - catch (IOException | NoSuchMethodException e) { - throw Caster.toPageException(e); - } + return getter.invoke(obj); } /** @@ -1205,7 +1226,12 @@ public static Object getProperty(Object obj, String prop) throws PageException { * @param prop property to call * @return property value */ + public static Object getProperty(Object obj, String prop, Object defaultValue) { + return getProperty(obj, prop, false, defaultValue); + } + + public static Object getProperty(Object obj, String prop, boolean nameCaseSensitive, Object defaultValue) { // first try field Field[] fields = getFieldsIgnoreCase(obj.getClass(), prop, null); @@ -1222,7 +1248,7 @@ public static Object getProperty(Object obj, String prop, Object defaultValue) { try { char first = prop.charAt(0); if (first >= '0' && first <= '9') return defaultValue; - return getGetter(obj.getClass(), prop).invoke(obj); + return getGetter(obj.getClass(), prop, nameCaseSensitive).invoke(obj); } catch (Throwable e1) { ExceptionUtil.rethrowIfNecessary(e1); @@ -1238,7 +1264,12 @@ public static Object getProperty(Object obj, String prop, Object defaultValue) { * @param value Value to assign * @throws PageException */ + public static void setProperty(Object obj, String prop, Object value) throws PageException { + setProperty(obj, prop, value, false); + } + + public static void setProperty(Object obj, String prop, Object value, boolean nameCaseSensitive) throws PageException { boolean done = false; try { if (setField(obj, prop, value)) done = true; @@ -1246,7 +1277,7 @@ public static void setProperty(Object obj, String prop, Object value) throws Pag catch (Throwable t) { ExceptionUtil.rethrowIfNecessary(t); } - if (!done) callSetter(obj, prop, value); + if (!done) callSetter(obj, prop, value, nameCaseSensitive); } /** @@ -1256,7 +1287,7 @@ public static void setProperty(Object obj, String prop, Object value) throws Pag * @param prop name of property * @param value Value to assign */ - public static void setPropertyEL(Object obj, String prop, Object value) { + public static void setPropertyEL(Object obj, String prop, Object value, boolean nameCaseSensitive) { // first check for field Field[] fields = getFieldsIgnoreCase(obj.getClass(), prop, null); @@ -1272,7 +1303,7 @@ public static void setPropertyEL(Object obj, String prop, Object value) { // then check for setter try { - getSetter(obj, prop, value).invoke(obj); + getSetter(obj, prop, value, nameCaseSensitive).invoke(obj); } catch (Throwable t) { ExceptionUtil.rethrowIfNecessary(t); @@ -1570,28 +1601,16 @@ public static Method getDeclaredMethod(Class clazz, String methodName, Class[ } } - public static Method getMethod(Class clazz, String methodName, Class[] args) throws NoSuchMethodException, IOException { - DynamicInvoker di = DynamicInvoker.getExistingInstance(); - try { - return di.getClazz(clazz, false).getMethod(methodName, args, true); - } - catch (IOException e) { - return di.getClazz(clazz, false).getMethod(methodName, args, false); - } + public static Method getMethod(Class clazz, String methodName, Class[] args, boolean nameCaseSensitive) throws NoSuchMethodException, IOException { + return DynamicInvoker.getExistingInstance().getClazz(clazz, false).getMethod(methodName, args, nameCaseSensitive); } - public static Method getMethod(Class clazz, String methodName, Class[] args, Method defaultValue) { - DynamicInvoker di = DynamicInvoker.getExistingInstance(); + public static Method getMethod(Class clazz, String methodName, Class[] args, boolean nameCaseSensitive, Method defaultValue) { try { - return di.getClazz(clazz, false).getMethod(methodName, args, true); + return DynamicInvoker.getExistingInstance().getClazz(clazz, false).getMethod(methodName, args, nameCaseSensitive); } catch (IOException e) { - try { - return di.getClazz(clazz, false).getMethod(methodName, args, false); - } - catch (Exception e1) { - return defaultValue; - } + return defaultValue; } catch (NoSuchMethodException e) { return defaultValue; diff --git a/core/src/main/java/lucee/runtime/reflection/pairs/ConstructorInstance.java b/core/src/main/java/lucee/runtime/reflection/pairs/ConstructorInstance.java index b5473c82bd..512926a024 100644 --- a/core/src/main/java/lucee/runtime/reflection/pairs/ConstructorInstance.java +++ b/core/src/main/java/lucee/runtime/reflection/pairs/ConstructorInstance.java @@ -28,6 +28,7 @@ import lucee.commons.lang.Pair; import lucee.runtime.exp.PageException; import lucee.runtime.op.Caster; +import lucee.runtime.type.Collection.Key; import lucee.transformer.dynamic.DynamicInvoker; import lucee.transformer.dynamic.meta.Clazz; import lucee.transformer.dynamic.meta.Constructor; @@ -106,7 +107,7 @@ public Constructor getConstructor(Constructor defaultValue) { private Pair getResult() throws PageException { if (result == null) { try { - result = DynamicInvoker.getExistingInstance().createInstance(clazz, null, args, convertComparsion); + result = DynamicInvoker.getExistingInstance().getInstance(clazz, (Key) null, args, true, convertComparsion); } catch (Exception e) { throw Caster.toPageException(e); diff --git a/core/src/main/java/lucee/runtime/reflection/pairs/MethodInstance.java b/core/src/main/java/lucee/runtime/reflection/pairs/MethodInstance.java index cdf4e434d5..21e94454ac 100644 --- a/core/src/main/java/lucee/runtime/reflection/pairs/MethodInstance.java +++ b/core/src/main/java/lucee/runtime/reflection/pairs/MethodInstance.java @@ -18,7 +18,6 @@ **/ package lucee.runtime.reflection.pairs; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.function.BiFunction; @@ -44,24 +43,27 @@ public final class MethodInstance { private Object[] args; private Pair result; private boolean convertComparsion; + private boolean nameCaseSensitive; + private FunctionMember fm; - public MethodInstance(Class clazz, Key methodName, Object[] args, boolean convertComparsion) { + public MethodInstance(Class clazz, FunctionMember fm, Object[] args, boolean nameCaseSensitive, boolean convertComparsion) { this.clazz = clazz; - this.methodName = methodName; + this.fm = fm; this.args = args; this.convertComparsion = convertComparsion; + this.nameCaseSensitive = nameCaseSensitive; } - public Object invoke(Object o) throws PageException, NoSuchMethodException, IOException { + public MethodInstance(Class clazz, Key methodName, Object[] args, boolean nameCaseSensitive, boolean convertComparsion) { + this.clazz = clazz; + this.methodName = methodName; + this.args = args; + this.convertComparsion = convertComparsion; + this.nameCaseSensitive = nameCaseSensitive; + } - if (o != null) { - if (args.length == 0 && "toString".equals(methodName.getString())) { - return o.toString(); - } - else if (args.length == 1 && "equals".equals(methodName.getString())) { - return o.equals(args[0]); - } - } + public Object invoke(Object o) throws PageException { + // if (Clazz.allowReflection()) print.e(Clazz.allowReflection()); try { return ((BiFunction) getResult().getValue()).apply(o, args); } @@ -69,8 +71,8 @@ else if (args.length == 1 && "equals".equals(methodName.getString())) { if (!Clazz.allowReflection()) throw e; LogUtil.log("dynamic", e); DynamicInvoker di = DynamicInvoker.getExistingInstance(); - lucee.transformer.dynamic.meta.Method method = Clazz.getMethodMatch(di.getClazz(clazz, true), methodName, args, true, true); try { + lucee.transformer.dynamic.meta.Method method = Clazz.getMethodMatch(di.getClazz(clazz, true), methodName, args, nameCaseSensitive, true, true); return ((LegacyMethod) method).getMethod().invoke(o, args); } catch (Exception e1) { @@ -125,7 +127,11 @@ else if (args.length == 1 && "equals".equals(methodName.getString())) { private Pair getResult() throws PageException { if (result == null) { try { - result = DynamicInvoker.getExistingInstance().createInstance(clazz, methodName, args, convertComparsion); + result = fm != null ? + + DynamicInvoker.getExistingInstance().getInstance(clazz, fm, args, nameCaseSensitive, convertComparsion) : + + DynamicInvoker.getExistingInstance().getInstance(clazz, methodName, args, nameCaseSensitive, convertComparsion); } catch (Throwable t) { ExceptionUtil.rethrowIfNecessary(t); diff --git a/core/src/main/java/lucee/runtime/tag/TagUtil.java b/core/src/main/java/lucee/runtime/tag/TagUtil.java index 12d34f19c1..12851c2f56 100755 --- a/core/src/main/java/lucee/runtime/tag/TagUtil.java +++ b/core/src/main/java/lucee/runtime/tag/TagUtil.java @@ -176,7 +176,7 @@ public static void setAttribute(PageContext pc, Tag tag, String name, Object val public static void setAttribute(PageContext pc, boolean doDynamic, boolean silently, Tag tag, String name, Object value) throws PageException { - MethodInstance setter = silently || doDynamic ? Reflector.getSetter(tag, name.toLowerCase(), value, null) : Reflector.getSetter(tag, name.toLowerCase(), value); + MethodInstance setter = silently || doDynamic ? Reflector.getSetter(tag, name.toLowerCase(), value, null) : Reflector.getSetter(tag, name.toLowerCase(), value, false); if (setter != null) { if (value == null) { diff --git a/core/src/main/java/lucee/runtime/type/QueryColumnImpl.java b/core/src/main/java/lucee/runtime/type/QueryColumnImpl.java index 3dbc786aac..7d2b70ea3f 100755 --- a/core/src/main/java/lucee/runtime/type/QueryColumnImpl.java +++ b/core/src/main/java/lucee/runtime/type/QueryColumnImpl.java @@ -695,7 +695,7 @@ public Object callWithNamedValues(PageContext pc, Key methodName, Struct args) t @Override public Object call(PageContext pc, Key methodName, Object[] arguments) throws PageException { - MethodInstance mi = Reflector.getMethodInstance(this.getClass(), methodName, arguments, false); + MethodInstance mi = Reflector.getMethodInstance(this.getClass(), methodName, arguments, false, false); if (mi.hasMethod()) { try { return mi.invoke(this); diff --git a/core/src/main/java/lucee/runtime/type/util/MemberUtil.java b/core/src/main/java/lucee/runtime/type/util/MemberUtil.java index a4371c45bb..5476ef4e0b 100644 --- a/core/src/main/java/lucee/runtime/type/util/MemberUtil.java +++ b/core/src/main/java/lucee/runtime/type/util/MemberUtil.java @@ -191,7 +191,7 @@ else if (args.length > ++argIndex) { // careful, argIndex is only incremented wh } private static Object callMethod(Object obj, Collection.Key methodName, Object[] args) throws PageException { - MethodInstance mi = Reflector.getMethodInstance(obj.getClass(), methodName, args, false); + MethodInstance mi = Reflector.getMethodInstance(obj.getClass(), methodName, args, false, false); if (!mi.hasMethod()) return DEFAULT; try { return mi.invoke(obj); diff --git a/core/src/main/java/lucee/runtime/util/ClassUtilImpl.java b/core/src/main/java/lucee/runtime/util/ClassUtilImpl.java index a0b7819763..4f7efcb437 100644 --- a/core/src/main/java/lucee/runtime/util/ClassUtilImpl.java +++ b/core/src/main/java/lucee/runtime/util/ClassUtilImpl.java @@ -188,12 +188,12 @@ public Object callConstructor(Class clazz, Object[] args, Object defaultValue @Override public Object callMethod(Object obj, Key methodName, Object[] args) throws PageException { - return Reflector.callMethod(obj, methodName, args); + return Reflector.callMethod(obj, methodName, args, false); } @Override public Object callMethod(Object obj, Key methodName, Object[] args, Object defaultValue) { - return Reflector.callMethod(obj, methodName, args, defaultValue); + return Reflector.callMethod(obj, methodName, args, false, defaultValue); } @Override @@ -218,7 +218,7 @@ public boolean setField(Object obj, String prop, Object value) throws PageExcept @Override public Object getProperty(Object obj, String prop) throws PageException { - return Reflector.getProperty(obj, prop); + return Reflector.getProperty(obj, prop, false); } @Override @@ -233,7 +233,7 @@ public void setProperty(Object obj, String prop, Object value) throws PageExcept @Override public void setPropertyEL(Object obj, String prop, Object value) { - Reflector.setPropertyEL(obj, prop, value); + Reflector.setPropertyEL(obj, prop, value, false); } @Override diff --git a/core/src/main/java/lucee/runtime/util/VariableUtilImpl.java b/core/src/main/java/lucee/runtime/util/VariableUtilImpl.java index 48bb6acc99..26308798b9 100755 --- a/core/src/main/java/lucee/runtime/util/VariableUtilImpl.java +++ b/core/src/main/java/lucee/runtime/util/VariableUtilImpl.java @@ -345,7 +345,7 @@ else if (coll instanceof TimeZone) { // Direct Object Access if (coll != null && pc.getConfig().getSecurityManager().getAccess(SecurityManager.TYPE_DIRECT_JAVA_ACCESS) == SecurityManager.VALUE_YES) { if (doLogReflectionCalls()) LogUtil.log(pc, Log.LEVEL_INFO, "reflection", "get-property:" + key + " from class " + Caster.toTypeName(coll)); - return Reflector.getProperty(coll, key.getString()); + return Reflector.getProperty(coll, key.getString(), false); } throw new ExpressionException("No matching property [" + key.getString() + "] found"); @@ -402,7 +402,7 @@ else if (coll instanceof Node) { // Direct Object Access if (pc.getConfig().getSecurityManager().getAccess(SecurityManager.TYPE_DIRECT_JAVA_ACCESS) == SecurityManager.VALUE_YES) { if (doLogReflectionCalls()) LogUtil.log(pc, Log.LEVEL_INFO, "reflection", "get-property:" + key + " from class " + Caster.toTypeName(coll)); - return Reflector.getProperty(coll, key); + return Reflector.getProperty(coll, key, false); } throw new ExpressionException("No matching property [" + key + "] found"); @@ -601,7 +601,7 @@ else if (coll instanceof Node) { // Direct Object Access if (pc.getConfig().getSecurityManager().getAccess(SecurityManager.TYPE_DIRECT_JAVA_ACCESS) == SecurityManager.VALUE_YES) { if (doLogReflectionCalls()) LogUtil.log(pc, Log.LEVEL_INFO, "reflection", "set-property:" + key + " in class " + Caster.toTypeName(coll)); - Reflector.setPropertyEL(coll, key, value); + Reflector.setPropertyEL(coll, key, value, false); return value; } return null; @@ -659,7 +659,7 @@ else if (coll instanceof Node) { // Direct Object Access if (pc.getConfig().getSecurityManager().getAccess(SecurityManager.TYPE_DIRECT_JAVA_ACCESS) == SecurityManager.VALUE_YES) { if (doLogReflectionCalls()) LogUtil.log(pc, Log.LEVEL_INFO, "reflection", "set-property:" + key + " in class " + Caster.toTypeName(coll)); - Reflector.setPropertyEL(coll, key.getString(), value); + Reflector.setPropertyEL(coll, key.getString(), value, false); return value; } return null; @@ -837,7 +837,10 @@ public Object callFunctionWithoutNamedValues(PageContext pc, Object coll, Collec // call Object Wrapper if (pc.getConfig().getSecurityManager().getAccess(SecurityManager.TYPE_DIRECT_JAVA_ACCESS) == SecurityManager.VALUE_YES) { if (doLogReflectionCalls()) LogUtil.log(pc, Log.LEVEL_INFO, "reflection", "call-method:" + key + " from class " + Caster.toTypeName(coll)); - if (!(coll instanceof Undefined)) return Reflector.callMethod(coll, key, args); + if (!(coll instanceof Undefined)) { + return Reflector.getMethodInstance(coll.getClass(), key, args, false, false).invoke(coll); + // return Reflector.callMethod(coll, key, args); + } } throw new ExpressionException("No matching Method/Function for " + key + "(" + Reflector.getDspMethods(Reflector.getClasses(args)) + ")"); diff --git a/core/src/main/java/lucee/transformer/dynamic/DynamicInvoker.java b/core/src/main/java/lucee/transformer/dynamic/DynamicInvoker.java index 1703119595..6c7515adb7 100644 --- a/core/src/main/java/lucee/transformer/dynamic/DynamicInvoker.java +++ b/core/src/main/java/lucee/transformer/dynamic/DynamicInvoker.java @@ -102,24 +102,24 @@ public static DynamicInvoker getExistingInstance() { return engine; } - public Object invokeStaticMethod(Class clazz, Key methodName, Object[] arguments, boolean convertComparsion) throws Exception { - return invoke(null, clazz, methodName, arguments, convertComparsion); + public Object invokeStaticMethod(Class clazz, Key methodName, Object[] arguments, boolean nameCaseSensitive, boolean convertComparsion) throws Exception { + return invoke(null, clazz, methodName, arguments, nameCaseSensitive, convertComparsion); } - public Object invokeStaticMethod(Class clazz, String methodName, Object[] arguments, boolean convertComparsion) throws Exception { - return invoke(null, clazz, KeyImpl.init(methodName), arguments, convertComparsion); + public Object invokeStaticMethod(Class clazz, String methodName, Object[] arguments, boolean nameCaseSensitive, boolean convertComparsion) throws Exception { + return invoke(null, clazz, KeyImpl.init(methodName), arguments, nameCaseSensitive, convertComparsion); } - public Object invokeInstanceMethod(Object obj, Key methodName, Object[] arguments, boolean convertComparsion) throws Exception { - return invoke(obj, obj.getClass(), methodName, arguments, convertComparsion); + public Object invokeInstanceMethod(Object obj, Key methodName, Object[] arguments, boolean nameCaseSensitive, boolean convertComparsion) throws Exception { + return invoke(obj, obj.getClass(), methodName, arguments, nameCaseSensitive, convertComparsion); } - public Object invokeInstanceMethod(Object obj, String methodName, Object[] arguments, boolean convertComparsion) throws Exception { - return invoke(obj, obj.getClass(), KeyImpl.init(methodName), arguments, convertComparsion); + public Object invokeInstanceMethod(Object obj, String methodName, Object[] arguments, boolean nameCaseSensitive, boolean convertComparsion) throws Exception { + return invoke(obj, obj.getClass(), KeyImpl.init(methodName), arguments, nameCaseSensitive, convertComparsion); } public Object invokeConstructor(Class clazz, Object[] arguments, boolean convertComparsion) throws Exception { - return invoke(null, clazz, null, arguments, convertComparsion); + return invoke(null, clazz, null, arguments, true, convertComparsion); } // TODO handles isStatic better with proper exceptions @@ -127,14 +127,15 @@ public Object invokeConstructor(Class clazz, Object[] arguments, boolean conv * executes a instance method of the given object * */ - private Object invoke(Object objMaybeNull, Class objClass, Key methodName, Object[] arguments, boolean convertComparsion) throws Exception { + private Object invoke(Object objMaybeNull, Class objClass, Key methodName, Object[] arguments, boolean nameCaseSensitive, boolean convertComparsion) throws Exception { try { - return ((BiFunction) createInstance(objClass, methodName, arguments, convertComparsion).getValue()).apply(objMaybeNull, arguments); + return ((BiFunction) getInstance(objClass, methodName, arguments, nameCaseSensitive, convertComparsion).getValue()).apply(objMaybeNull, + arguments); } catch (IncompatibleClassChangeError | IllegalStateException e) { if (log != null) log.error("dynamic", e); if (!Clazz.allowReflection()) throw e; - lucee.transformer.dynamic.meta.Method method = Clazz.getMethodMatch(getClazz(objClass, true), methodName, arguments, true, convertComparsion); + lucee.transformer.dynamic.meta.Method method = Clazz.getMethodMatch(getClazz(objClass, true), methodName, arguments, nameCaseSensitive, true, convertComparsion); return ((LegacyMethod) method).getMethod().invoke(objClass, arguments); } } @@ -154,33 +155,26 @@ public Clazz getClazz(Class clazz, boolean useReflection) { private static double clsLoader = 0; private static double loadInstance = 0; - public Pair createInstance(Class clazz, Key methodName, Object[] arguments, boolean convertComparsion) throws NoSuchMethodException, IOException, - UnmodifiableClassException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, PageException { + public Pair getInstance(Class clazz, Key methodName, Object[] arguments, boolean nameCaseSensitive, boolean convertComparsion) + throws NoSuchMethodException, IOException, UnmodifiableClassException, InstantiationException, IllegalAccessException, IllegalArgumentException, + InvocationTargetException, SecurityException, PageException { // double start = SystemUtil.millis(); boolean isConstr = methodName == null; // Clazz clazzz = getClazz(clazz); - Clazz clazzz = ClazzDynamic.getInstance(clazz, root, log); + ClazzDynamic clazzz = ClazzDynamic.getInstance(clazz, root, log); // Clazz clazzz = new ClazzReflection(clazz); // getClass -= start; // start = SystemUtil.millis(); // getClass += start; + lucee.transformer.dynamic.meta.FunctionMember fm = isConstr ? Clazz.getConstructorMatch(clazzz, arguments, true, convertComparsion) + : Clazz.getMethodMatch(clazzz, methodName, arguments, nameCaseSensitive, true, convertComparsion); - lucee.transformer.dynamic.meta.FunctionMember fm = null; - lucee.transformer.dynamic.meta.Method method = null; - // - if (isConstr) { - fm = Clazz.getConstructorMatch(clazzz, arguments, true, convertComparsion); - } - else { - // Clazz clazz, final Collection.Key methodName, final Object[] args, boolean convertArgument - fm = method = Clazz.getMethodMatch(clazzz, methodName, arguments, true, convertComparsion); - } // match -= start; // start = SystemUtil.millis(); // match += start; - - clazz = fm.getDeclaringClass(); // we wanna go as low as possible, to be as open as possible also this avoid not allow to access + // clazz = fm.getDeclaringClass(); // we wanna go as low as possible, to be as open as possible also + // this avoid not allow to access // getDeclaringClass -= start; // start = SystemUtil.millis(); @@ -192,7 +186,7 @@ public Pair createInstance(Class clazz, Key methodNam // start = SystemUtil.millis(); // pathName += start; - DynamicClassLoader loader = getCL(clazz); + DynamicClassLoader loader = clazzz.getDynamicClassLoader(this); // clsLoader -= start; // start = SystemUtil.millis(); @@ -212,6 +206,36 @@ public Pair createInstance(Class clazz, Key methodNam // loadInstance += start; // } } + + return createInstance(clazzz, fm, isConstr, className, loader); + + } + + public Pair getInstance(Class clazz, final lucee.transformer.dynamic.meta.FunctionMember fm, Object[] arguments, boolean nameCaseSensitive, + boolean convertComparsion) throws NoSuchMethodException, IOException, UnmodifiableClassException, InstantiationException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException, SecurityException { + + boolean isConstr = fm instanceof lucee.transformer.dynamic.meta.Constructor; + ClazzDynamic clazzz = ClazzDynamic.getInstance(clazz, root, log); + String className = fm.getClassName(); + DynamicClassLoader loader = clazzz.getDynamicClassLoader(this); + + if (loader.hasClass(className)) { + try { + return new Pair(fm, loader.loadInstance(className)); + + } + catch (Exception e) { + // simply ignore when fail + } + } + return createInstance(clazzz, fm, isConstr, className, loader); + } + + private Pair createInstance(ClazzDynamic clazzz, lucee.transformer.dynamic.meta.FunctionMember fm, boolean isConstr, String className, + DynamicClassLoader loader) throws NoSuchMethodException, IOException, UnmodifiableClassException, InstantiationException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException, SecurityException { + synchronized (SystemUtil.createToken("dyninvocer", className)) { Class[] parameterClasses = fm.getArgumentClasses(); @@ -236,7 +260,7 @@ public Pair createInstance(Class clazz, Key methodNam mv.visitCode(); boolean isStatic = true; if (isConstr) { - mv.visitTypeInsn(Opcodes.NEW, Type.getType(clazz).getInternalName()); + mv.visitTypeInsn(Opcodes.NEW, Type.getType(clazzz.getDeclaringClass()).getInternalName()); mv.visitInsn(Opcodes.DUP); // Duplicate the top operand stack value } @@ -294,12 +318,12 @@ public Pair createInstance(Class clazz, Key methodNam } Type rt; if (isConstr) { - rt = Type.getType(clazz); + rt = Type.getType(clazzz.getDeclaringClass()); } else { - Class tmp = method.getDeclaringProviderRtnClassWithSameAccess(); + Class tmp = ((lucee.transformer.dynamic.meta.Method) fm).getDeclaringProviderRtnClassWithSameAccess(); if (tmp != null) rt = Type.getType(tmp); - else rt = method.getReturnType(); + else rt = fm.getReturnType(); } methodDesc.append(')').append(isConstr ? Types.VOID : rt.getDescriptor()); @@ -309,7 +333,7 @@ public Pair createInstance(Class clazz, Key methodNam } else { mv.visitMethodInsn(isStatic ? Opcodes.INVOKESTATIC : (fm.getDeclaringProviderClassWithSameAccess().isInterface() ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL), - Type.getInternalName(fm.getDeclaringProviderClassWithSameAccess()), method.getName(), methodDesc.toString(), + Type.getInternalName(fm.getDeclaringProviderClassWithSameAccess()), fm.getName(), methodDesc.toString(), fm.getDeclaringProviderClassWithSameAccess().isInterface()); } @@ -382,7 +406,7 @@ private static void boxIfPrimitive(MethodVisitor mv, Type returnType) { } } - private DynamicClassLoader getCL(Class clazz) { + public DynamicClassLoader getCL(Class clazz) { ClassLoader parent = clazz.getClassLoader(); if (parent == null) parent = SystemUtil.getCombinedClassLoader(); DynamicClassLoader cl = loaders.get(parent.hashCode()); @@ -453,6 +477,7 @@ public static void main(String[] args) throws Throwable { int max = 500000; long dynamicInvoker = Long.MAX_VALUE; long dynamicInvoker2 = Long.MAX_VALUE; + long dynamicInvoker3 = Long.MAX_VALUE; long reflection = Long.MAX_VALUE; long direct = Long.MAX_VALUE; long methodHandle = Long.MAX_VALUE; @@ -460,7 +485,7 @@ public static void main(String[] args) throws Throwable { TestMule tm = new TestMule(); Class clazz = tm.getClass(); Class[] cargs = new Class[] { int.class }; - + Key methodName = new KeyImpl("Test"); e.invokeConstructor(clazz, new Object[] { 1 }, false); e.invokeConstructor(String.class, new Object[] { "" }, false); @@ -478,7 +503,7 @@ public static void main(String[] args) throws Throwable { for (int i = 0; i < rounds; i++) { long start = System.currentTimeMillis(); for (int y = 0; y < max; y++) { - e.invokeInstanceMethod(tm, "test", new Object[] { 1 }, false); + e.invokeInstanceMethod(tm, "test", new Object[] { 1 }, false, false); } tmp = System.currentTimeMillis() - start; if (tmp < dynamicInvoker) dynamicInvoker = tmp; @@ -488,12 +513,23 @@ public static void main(String[] args) throws Throwable { for (int i = 0; i < rounds; i++) { long start = System.currentTimeMillis(); for (int y = 0; y < max; y++) { - Reflector.getMethod(clazz, "test", cargs).invoke(tm, new Object[] { 1 }); + // Reflector.getMethodInstance(clazz, methodName, new Object[] { 1 }, false, false).invoke(tm); + Reflector.getMethod(clazz, "test", cargs, true).invoke(tm, new Object[] { 1 }); } tmp = System.currentTimeMillis() - start; if (tmp < dynamicInvoker2) dynamicInvoker2 = tmp; } + // invokeInstanceMethod + for (int i = 0; i < rounds; i++) { + long start = System.currentTimeMillis(); + for (int y = 0; y < max; y++) { + Reflector.callMethod(tm, methodName, new Object[] { 1 }, false); + } + tmp = System.currentTimeMillis() - start; + if (tmp < dynamicInvoker3) dynamicInvoker3 = tmp; + } + // MethodHandles MethodHandles.Lookup lookup = MethodHandles.lookup(); for (int i = 0; i < rounds; i++) { @@ -518,8 +554,9 @@ public static void main(String[] args) throws Throwable { if (tmp < direct) direct = tmp; } - aprint.e("dynamicInvoker2:" + dynamicInvoker2); - aprint.e("dynamicInvoker:" + dynamicInvoker); + aprint.e("invokeInstanceMethod:" + dynamicInvoker); + aprint.e("Reflector.getMethod:" + dynamicInvoker2); + aprint.e("Reflector.callMethod:" + dynamicInvoker3); aprint.e("reflection:" + reflection); aprint.e("methodHandle:" + reflection); aprint.e("direct:" + direct); @@ -583,7 +620,7 @@ public static void main(String[] args) throws Throwable { map.put("aaa", "sss"); Iterator it = map.keySet().iterator(); // aprint.e(e.invokeInstanceMethod(it, "next", new Object[] {}, false)); - aprint.e(e.invokeInstanceMethod(it, "hasNext", new Object[] {}, false)); + aprint.e(e.invokeInstanceMethod(it, "hasNext", new Object[] {}, true, false)); if (false) { FileInputStream fis = new java.io.FileInputStream("/Users/mic/Tmp3/test.prop"); @@ -591,12 +628,12 @@ public static void main(String[] args) throws Throwable { PropertyResourceBundle prb = new java.util.PropertyResourceBundle(fir); Enumeration keys = prb.getKeys(); String key; - aprint.e(e.invokeInstanceMethod(keys, "hasMoreElements", new Object[] {}, false)); + aprint.e(e.invokeInstanceMethod(keys, "hasMoreElements", new Object[] {}, true, false)); while (keys.hasMoreElements()) { - key = (String) e.invokeInstanceMethod(keys, "nextElement", new Object[] {}, false); + key = (String) e.invokeInstanceMethod(keys, "nextElement", new Object[] {}, true, false); aprint.e(key); aprint.e(prb.handleGetObject(key)); - aprint.e(e.invokeInstanceMethod(prb, "handleGetObject", new Object[] { key }, false)); + aprint.e(e.invokeInstanceMethod(prb, "handleGetObject", new Object[] { key }, true, false)); } fis.close(); System.exit(0); @@ -610,12 +647,12 @@ public static void main(String[] args) throws Throwable { // dump( now().toInstant().atZone( zoneId.of( "US/Central" ) ).toLocalDateTime() // .with( ChronoField.DAY_OF_WEEK, javacast( "long", 1 ) )) - ZoneId zoneId = (ZoneId) e.invokeStaticMethod(java.time.ZoneId.class, "of", new Object[] { "US/Central" }, false); - Instant instant = (Instant) e.invokeInstanceMethod(new DateTimeImpl(), "toInstant", new Object[] {}, false); + ZoneId zoneId = (ZoneId) e.invokeStaticMethod(java.time.ZoneId.class, "of", new Object[] { "US/Central" }, true, false); + Instant instant = (Instant) e.invokeInstanceMethod(new DateTimeImpl(), "toInstant", new Object[] {}, true, false); - ZonedDateTime zdt = (ZonedDateTime) e.invokeInstanceMethod(instant, "atZone", new Object[] { zoneId }, false); - LocalDateTime ldt = (LocalDateTime) e.invokeInstanceMethod(zdt, "toLocalDateTime", new Object[] {}, false); - Object r = e.invokeInstanceMethod(ldt, "with", new Object[] { ChronoField.DAY_OF_WEEK, 1L }, false); + ZonedDateTime zdt = (ZonedDateTime) e.invokeInstanceMethod(instant, "atZone", new Object[] { zoneId }, true, false); + LocalDateTime ldt = (LocalDateTime) e.invokeInstanceMethod(zdt, "toLocalDateTime", new Object[] {}, true, false); + Object r = e.invokeInstanceMethod(ldt, "with", new Object[] { ChronoField.DAY_OF_WEEK, 1L }, true, false); aprint.e(r); } @@ -630,12 +667,12 @@ public static void main(String[] args) throws Throwable { TimeZone tz = java.util.TimeZone.getDefault(); ArrayList arr = new ArrayList<>(); - Object sadas1 = e.invokeInstanceMethod(sb, "append", new Object[] { "sss" }, false); + Object sadas1 = e.invokeInstanceMethod(sb, "append", new Object[] { "sss" }, true, false); aprint.e(sadas1); // java.util.HashMap.EntrySet Thread.getAllStackTraces().entrySet().iterator(); - Object sadasd = e.invokeInstanceMethod(Thread.getAllStackTraces().entrySet(), "iterator", new Object[] {}, false); + Object sadasd = e.invokeInstanceMethod(Thread.getAllStackTraces().entrySet(), "iterator", new Object[] {}, true, false); // System.exit(0); String str = new String("Susi exclusive"); aprint.e(str); @@ -643,14 +680,14 @@ public static void main(String[] args) throws Throwable { // System.exit(0); - Object eee = e.invokeInstanceMethod(t, "setSource", new Object[] { "" }, false); + Object eee = e.invokeInstanceMethod(t, "setSource", new Object[] { "" }, true, false); // System.exit(0); // source // instance ():String { Object reflection = tz.getID(); - Object dynamic = e.invokeInstanceMethod(tz, "getID", new Object[] {}, false); + Object dynamic = e.invokeInstanceMethod(tz, "getID", new Object[] {}, true, false); if (!reflection.equals(dynamic)) { aprint.e("direct:"); aprint.e(reflection); @@ -662,7 +699,7 @@ public static void main(String[] args) throws Throwable { // instance (double->int):String { Object reflection = t.test(134); - Object dynamic = e.invokeInstanceMethod(t, "test", new Object[] { 134D }, true); + Object dynamic = e.invokeInstanceMethod(t, "test", new Object[] { 134D }, true, true); if (!reflection.equals(dynamic)) { aprint.e("direct:"); aprint.e(reflection); @@ -674,7 +711,7 @@ public static void main(String[] args) throws Throwable { // instance (double->int):String { Object reflection = t.test(134); - Object dynamic = e.invokeInstanceMethod(t, "test", new Object[] { 134D }, true); + Object dynamic = e.invokeInstanceMethod(t, "test", new Object[] { 134D }, true, true); if (!reflection.equals(dynamic)) { aprint.e("direct:"); aprint.e(reflection); @@ -684,23 +721,23 @@ public static void main(String[] args) throws Throwable { } aprint.e(t.complete("", 1, null)); - aprint.e(e.invokeInstanceMethod(t, "complete", new Object[] { "", i, null }, true)); - aprint.e(e.invokeInstanceMethod(t, "complete", new Object[] { "", bd, null }, true)); + aprint.e(e.invokeInstanceMethod(t, "complete", new Object[] { "", i, null }, true, true)); + aprint.e(e.invokeInstanceMethod(t, "complete", new Object[] { "", bd, null }, true, true)); aprint.e(t.testb(true, true)); - aprint.e(e.invokeInstanceMethod(t, "testb", new Object[] { null, true }, true)); + aprint.e(e.invokeInstanceMethod(t, "testb", new Object[] { null, true }, true, true)); aprint.e(t.testStr(1, "string", 1L)); - aprint.e(e.invokeInstanceMethod(t, "testStr", new Object[] { "1", 1, Double.valueOf(1D) }, true)); + aprint.e(e.invokeInstanceMethod(t, "testStr", new Object[] { "1", 1, Double.valueOf(1D) }, true, true)); - aprint.e(e.invokeInstanceMethod(t, "test", new Object[] { "1" }, true)); - aprint.e(e.invokeInstanceMethod(t, "test", new Object[] { 1D }, true)); + aprint.e(e.invokeInstanceMethod(t, "test", new Object[] { "1" }, true, true)); + aprint.e(e.invokeInstanceMethod(t, "test", new Object[] { 1D }, true, true)); - aprint.e(e.invokeInstanceMethod(new SystemOut(), "setOut", new Object[] { null }, true)); + aprint.e(e.invokeInstanceMethod(new SystemOut(), "setOut", new Object[] { null }, true, true)); System.setProperty("a.b.c", "- value -"); - aprint.e(e.invokeInstanceMethod(sb, "toSTring", new Object[] {}, false)); - aprint.e(e.invokeStaticMethod(SystemUtil.class, "getSystemPropOrEnvVar", new Object[] { "a.b.c", "default-value" }, true)); - aprint.e(e.invokeStaticMethod(ListUtil.class, "arrayToList", new Object[] { new String[] { "a", "b" }, "," }, true)); + aprint.e(e.invokeInstanceMethod(sb, "toSTring", new Object[] {}, true, false)); + aprint.e(e.invokeStaticMethod(SystemUtil.class, "getSystemPropOrEnvVar", new Object[] { "a.b.c", "default-value" }, true, true)); + aprint.e(e.invokeStaticMethod(ListUtil.class, "arrayToList", new Object[] { new String[] { "a", "b" }, "," }, true, true)); aprint.e("done"); } diff --git a/core/src/main/java/lucee/transformer/dynamic/meta/Clazz.java b/core/src/main/java/lucee/transformer/dynamic/meta/Clazz.java index 474103fb47..fceb473814 100644 --- a/core/src/main/java/lucee/transformer/dynamic/meta/Clazz.java +++ b/core/src/main/java/lucee/transformer/dynamic/meta/Clazz.java @@ -27,6 +27,8 @@ import lucee.runtime.reflection.Reflector; import lucee.runtime.type.Collection; import lucee.transformer.bytecode.util.ASMUtil; +import lucee.transformer.dynamic.DynamicClassLoader; +import lucee.transformer.dynamic.DynamicInvoker; import lucee.transformer.dynamic.meta.dynamic.ClazzDynamic; import lucee.transformer.dynamic.meta.reflection.ClazzReflection; @@ -37,6 +39,8 @@ public abstract class Clazz implements Serializable { private static final long serialVersionUID = 4236939474343760825L; private static Boolean allowReflection = null; + private DynamicClassLoader dcl; + public abstract List getMethods(String methodName, boolean nameCaseSensitive, int argumentLength) throws IOException; public abstract List getDeclaredMethods(String methodName, boolean nameCaseSensitive, int argumentLength) throws IOException; @@ -97,7 +101,7 @@ public static Clazz getClazz(Class clazz, Resource root, Log log) { private static Map>> cachedMethods = new ConcurrentHashMap<>(); - public static Method getMethodMatch(Clazz clazz, final Collection.Key methodName, Object[] args, boolean convertArgument, boolean convertComparsion) + public static Method getMethodMatch(Clazz clazz, final Collection.Key methodName, Object[] args, boolean nameCaseSensitive, boolean convertArgument, boolean convertComparsion) throws NoSuchMethodException, IOException, PageException { List methods = clazz.getMethods(methodName.getString(), false, args.length); @@ -371,6 +375,13 @@ public static ClassLoader getClassLoader(Class clazz) { return tmp; } + public DynamicClassLoader getDynamicClassLoader(DynamicInvoker dynamicInvoker) { + if (dcl == null) { + dcl = dynamicInvoker.getCL(getDeclaringClass()); + } + return dcl; + } + public static Type[] toTypes(Class[] classes) { Type[] types = new Type[classes.length]; for (int i = 0; i < classes.length; i++) { diff --git a/core/src/main/java/lucee/transformer/dynamic/meta/FunctionMember.java b/core/src/main/java/lucee/transformer/dynamic/meta/FunctionMember.java index 3d1ba554b7..2549180255 100644 --- a/core/src/main/java/lucee/transformer/dynamic/meta/FunctionMember.java +++ b/core/src/main/java/lucee/transformer/dynamic/meta/FunctionMember.java @@ -54,6 +54,12 @@ public interface FunctionMember extends Serializable { public abstract String getClassName(); + public abstract String getReturn(); + + public abstract Type getReturnType(); + + public abstract Class getReturnClass(); + public static String createClassPath(FunctionMember fm) { StringBuilder sbClassPath = new StringBuilder(); // sbClassPath.append(getDeclaringClassName().replace('.', '/')).append('/').append(isConstr ? diff --git a/core/src/main/java/lucee/transformer/dynamic/meta/Method.java b/core/src/main/java/lucee/transformer/dynamic/meta/Method.java index 5149a9e4cf..2e16e8b2a2 100644 --- a/core/src/main/java/lucee/transformer/dynamic/meta/Method.java +++ b/core/src/main/java/lucee/transformer/dynamic/meta/Method.java @@ -2,14 +2,7 @@ import java.io.IOException; -import org.objectweb.asm.Type; - public interface Method extends FunctionMember { - public String getReturn(); - - public Type getReturnType(); - - public Class getReturnClass(); public String getDeclaringProviderRtnClassName(); diff --git a/core/src/main/java/lucee/transformer/dynamic/meta/dynamic/ClazzDynamic.java b/core/src/main/java/lucee/transformer/dynamic/meta/dynamic/ClazzDynamic.java index 73f2beaf76..d54dd4a7c4 100644 --- a/core/src/main/java/lucee/transformer/dynamic/meta/dynamic/ClazzDynamic.java +++ b/core/src/main/java/lucee/transformer/dynamic/meta/dynamic/ClazzDynamic.java @@ -48,13 +48,14 @@ public class ClazzDynamic extends Clazz { private transient Class clazz; // private static Map> classes = new ConcurrentHashMap<>(); - private final FunctionMember[] methods; - private final FunctionMember[] declaredMethods; - private final FunctionMember[] constructors; - private final FunctionMember[] declaredConstructors; + private final Method[] methods; + private final Method[] declaredMethods; + private final Constructor[] constructors; + private final Constructor[] declaredConstructors; private String clid; private String id; + private static Map clids = new IdentityHashMap<>(); private static String systemId; @@ -183,24 +184,24 @@ private ClazzDynamic(Class clazz, String clid, Log log) throws IOException { this.clid = clid; Map members = getFunctionMembers(this.clid, clazz, log); - LinkedList tmpMethods = new LinkedList<>(); - LinkedList tmpDeclaredMethods = new LinkedList<>(); - LinkedList tmpConstructors = new LinkedList<>(); - LinkedList tmpDeclaredConstructors = new LinkedList<>(); + LinkedList tmpMethods = new LinkedList<>(); + LinkedList tmpDeclaredMethods = new LinkedList<>(); + LinkedList tmpConstructors = new LinkedList<>(); + LinkedList tmpDeclaredConstructors = new LinkedList<>(); for (FunctionMember fm: members.values()) { if (fm instanceof Method) { - if (clazz.getName().equals(fm.getDeclaringClassName())) tmpDeclaredMethods.add(fm); - if (fm.isPublic()) tmpMethods.add(fm); + if (clazz.getName().equals(fm.getDeclaringClassName())) tmpDeclaredMethods.add((Method) fm); + if (fm.isPublic()) tmpMethods.add((Method) fm); } else if (fm instanceof Constructor) { - if (clazz.getName().equals(fm.getDeclaringClassName())) tmpDeclaredConstructors.add(fm); - if (fm.isPublic()) tmpConstructors.add(fm); + if (clazz.getName().equals(fm.getDeclaringClassName())) tmpDeclaredConstructors.add((Constructor) fm); + if (fm.isPublic()) tmpConstructors.add((Constructor) fm); } } - methods = tmpMethods.toArray(new FunctionMember[tmpMethods.size()]); - declaredMethods = tmpDeclaredMethods.toArray(new FunctionMember[tmpDeclaredMethods.size()]); - constructors = tmpConstructors.toArray(new FunctionMember[tmpConstructors.size()]); - declaredConstructors = tmpDeclaredConstructors.toArray(new FunctionMember[tmpDeclaredConstructors.size()]); + methods = tmpMethods.toArray(new Method[tmpMethods.size()]); + declaredMethods = tmpDeclaredMethods.toArray(new Method[tmpDeclaredMethods.size()]); + constructors = tmpConstructors.toArray(new Constructor[tmpConstructors.size()]); + declaredConstructors = tmpDeclaredConstructors.toArray(new Constructor[tmpDeclaredConstructors.size()]); } @@ -296,7 +297,7 @@ public Constructor getDeclaredConstructor(Class[] arguments) throws IOException, @Override public List getMethods(String methodName, boolean nameCaseSensitive, int argumentLength) { List list = new LinkedList<>(); - for (FunctionMember fm: methods) { + for (Method fm: methods) { if (/* fm.isPublic() && */ (argumentLength == fm.getArgumentCount() || argumentLength < 0) && @@ -304,7 +305,7 @@ public List getMethods(String methodName, boolean nameCaseSensitive, int (methodName == null || (nameCaseSensitive ? methodName.equals(fm.getName()) : methodName.equalsIgnoreCase(fm.getName()))) ) { - list.add((Method) fm); + list.add(fm); } } return list; @@ -313,7 +314,7 @@ public List getMethods(String methodName, boolean nameCaseSensitive, int @Override public List getDeclaredMethods(String methodName, boolean nameCaseSensitive, int argumentLength) throws IOException { List list = new LinkedList<>(); - for (FunctionMember fm: declaredMethods) { + for (Method fm: declaredMethods) { if ((argumentLength < 0 || argumentLength == fm.getArgumentCount()) && (methodName == null || (nameCaseSensitive ? methodName.equals(fm.getName()) : methodName.equalsIgnoreCase(fm.getName()))) @@ -321,7 +322,7 @@ public List getDeclaredMethods(String methodName, boolean nameCaseSensit /* &&clazz.getName().equals(fm.getDeclaringClassName()) */ ) { - list.add((Method) fm); + list.add(fm); } } return list; @@ -331,7 +332,7 @@ public List getDeclaredMethods(String methodName, boolean nameCaseSensit public List getConstructors(int argumentLength) throws IOException { List list = new LinkedList<>(); - for (FunctionMember fm: constructors) { + for (Constructor fm: constructors) { if (/* fm.isPublic() && */ (argumentLength < 0 || argumentLength == fm.getArgumentCount()) && @@ -339,7 +340,7 @@ public List getConstructors(int argumentLength) throws IOException clazz.getName().equals(fm.getDeclaringClassName()) ) { - list.add((Constructor) fm); + list.add(fm); } } return list; @@ -348,13 +349,13 @@ public List getConstructors(int argumentLength) throws IOException @Override public List getDeclaredConstructors(int argumentLength) throws IOException { List list = new LinkedList<>(); - for (FunctionMember fm: declaredConstructors) { + for (Constructor fm: declaredConstructors) { if ((argumentLength < 0 || argumentLength == fm.getArgumentCount()) /* && clazz.getName().equals(fm.getDeclaringClassName()) */ ) { - list.add((Constructor) fm); + list.add(fm); } } return list; diff --git a/core/src/main/java/lucee/transformer/dynamic/meta/dynamic/MethodDynamic.java b/core/src/main/java/lucee/transformer/dynamic/meta/dynamic/MethodDynamic.java index 57d8573b32..afeb93ceab 100644 --- a/core/src/main/java/lucee/transformer/dynamic/meta/dynamic/MethodDynamic.java +++ b/core/src/main/java/lucee/transformer/dynamic/meta/dynamic/MethodDynamic.java @@ -5,7 +5,6 @@ import lucee.commons.lang.ExceptionUtil; import lucee.runtime.reflection.Reflector; import lucee.runtime.reflection.pairs.MethodInstance; -import lucee.runtime.type.KeyImpl; import lucee.transformer.dynamic.meta.Method; class MethodDynamic extends FunctionMemberDynamic implements Method { @@ -19,11 +18,12 @@ public MethodDynamic(Class declaringClass, String name) { @Override public Object invoke(Object obj, Object... args) throws IOException { // TODO is there a better way to do this? - MethodInstance mi = Reflector.getMethodInstance(getDeclaringClass(), KeyImpl.init(getName()), args, false); + MethodInstance mi = Reflector.getMethodInstance(getDeclaringClass(), this, args, false, false); try { return mi.invoke(obj); } catch (Exception e) { + throw ExceptionUtil.toIOException(e); } } diff --git a/core/src/main/java/lucee/transformer/dynamic/meta/reflection/ConstructorReflection.java b/core/src/main/java/lucee/transformer/dynamic/meta/reflection/ConstructorReflection.java index 2d13d9c9e4..8c6da0f2ce 100644 --- a/core/src/main/java/lucee/transformer/dynamic/meta/reflection/ConstructorReflection.java +++ b/core/src/main/java/lucee/transformer/dynamic/meta/reflection/ConstructorReflection.java @@ -2,6 +2,8 @@ import java.io.IOException; +import org.objectweb.asm.Type; + import lucee.commons.lang.ExceptionUtil; import lucee.transformer.dynamic.meta.Constructor; import lucee.transformer.dynamic.meta.LegacyConstuctor; @@ -29,4 +31,19 @@ public Object newInstance(Object... args) throws IOException { throw ExceptionUtil.toIOException(e); } } + + @Override + public String getReturn() { + return getReturnClass().getName(); + } + + @Override + public Type getReturnType() { + return Type.getType(getDeclaringClass()); + } + + @Override + public Class getReturnClass() { + return getDeclaringClass(); + } } diff --git a/loader/build.xml b/loader/build.xml index a464e11fcd..74295ae61f 100644 --- a/loader/build.xml +++ b/loader/build.xml @@ -2,7 +2,7 @@ - + diff --git a/loader/pom.xml b/loader/pom.xml index 47f4e92701..73121a6d03 100644 --- a/loader/pom.xml +++ b/loader/pom.xml @@ -3,7 +3,7 @@ org.lucee lucee - 6.2.0.227-SNAPSHOT + 6.2.0.228-SNAPSHOT jar Lucee Loader Build