Skip to content

Commit

Permalink
LDEV-5238 - hadle arrays as Object
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Jan 6, 2025
1 parent fc5100b commit 4751c57
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
14 changes: 11 additions & 3 deletions core/src/main/java/lucee/transformer/dynamic/DynamicInvoker.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public Object invokeConstructor(Class<?> clazz, Object[] arguments, boolean conv
*/
private Object invoke(Object objMaybeNull, Class<?> objClass, Key methodName, Object[] arguments, boolean nameCaseSensitive, boolean convertComparsion) throws Exception {
try {
if (objClass.isArray()) objClass = Object.class;
ClazzDynamic clazzz = toClazzDynamic(objClass);

return ((BiFunction<Object, Object[], Object>) getInstance(clazzz, getFunctionMember(clazzz, methodName, arguments, nameCaseSensitive, convertComparsion), arguments))
.apply(objMaybeNull, arguments);
}
Expand Down Expand Up @@ -425,7 +425,7 @@ public static void main(String[] argsw) throws Throwable {
DynamicInvoker e = new DynamicInvoker(classes);

DynamicInvoker.getInstance(classes);
{
if (true) {

int rounds = 6;
int max = 500000;
Expand Down Expand Up @@ -469,6 +469,7 @@ public static void main(String[] argsw) throws Throwable {
long start = System.currentTimeMillis();
for (int y = 0; y < max; y++) {
// Reflector.getMethodInstance(clazz, methodName, new Object[] { 1 }, false, false).invoke(tm);
// Reflector.getMethod(clazz, "test", cargs, true);
Reflector.getMethod(clazz, "test", cargs, true).invoke(tm, args);
}
tmp = System.currentTimeMillis() - start;
Expand Down Expand Up @@ -513,7 +514,7 @@ public static void main(String[] argsw) throws Throwable {
aprint.e("Reflector.getMethod:" + dynamicInvoker2);
aprint.e("Reflector.callMethod:" + dynamicInvoker3);
aprint.e("reflection:" + reflection);
aprint.e("methodHandle:" + reflection);
aprint.e("methodHandle:" + methodHandle);
aprint.e("direct:" + direct);

aprint.e("-------------------");
Expand Down Expand Up @@ -594,6 +595,13 @@ public static void main(String[] argsw) throws Throwable {
System.exit(0);
}

{

int[] arr = new int[] { 1, 2 };

aprint.e(e.invokeInstanceMethod(arr, "toString", new Object[] {}, true, false));
}

{

// zoneId = createObject( "java", "java.time.ZoneId" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,8 @@ private static Map<String, FunctionMember> getFunctionMembers(final Class clazz,
return _getFunctionMembers(clazz, log);
}

private static Map<String, FunctionMember> _getFunctionMembers(final Class clazz, Log log) throws IOException {

private static Map<String, FunctionMember> _getFunctionMembers(Class clazz_, Log log) throws IOException {
final Class clazz = clazz_.isArray() ? Object.class : clazz_;
final Map<String, FunctionMember> members = new LinkedHashMap<>();
Map<String, FunctionMember> existing = membersCollection.get(clazz);

Expand Down
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="6.2.0.271-SNAPSHOT"/>
<property name="version" value="6.2.0.272-SNAPSHOT"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>6.2.0.271-SNAPSHOT</version>
<version>6.2.0.272-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down

0 comments on commit 4751c57

Please sign in to comment.