This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.scripting.sightly.compiler-1.0.10 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-compiler.git
commit c0cc4ef79d002ad509800ddf33b963c23ec46c37 Author: Radu Cotescu <[email protected]> AuthorDate: Wed Jan 11 11:57:58 2017 +0000 SLING-6450 - [HTL] Cannot retrieve "length" property for arrays of primitive types * treated all arrays in a unitary way, irrespective of their type, for "length" retrieval git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/scripting/sightly/compiler@1778282 13f79535-47bb-0310-9956-ffa450edef68 --- .../scripting/sightly/impl/compiler/CompileTimeObjectModel.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/sling/scripting/sightly/impl/compiler/CompileTimeObjectModel.java b/src/main/java/org/apache/sling/scripting/sightly/impl/compiler/CompileTimeObjectModel.java index af8bfc7..a01ad50 100644 --- a/src/main/java/org/apache/sling/scripting/sightly/impl/compiler/CompileTimeObjectModel.java +++ b/src/main/java/org/apache/sling/scripting/sightly/impl/compiler/CompileTimeObjectModel.java @@ -16,6 +16,7 @@ ******************************************************************************/ package org.apache.sling.scripting.sightly.impl.compiler; +import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -281,11 +282,10 @@ public final class CompileTimeObjectModel { } private static Object getField(Object obj, String property) { - if (obj instanceof Object[] && "length".equals(property)) { - // Working around this limitation: http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getFields%28%29 - return ((Object[]) obj).length; - } Class<?> cls = obj.getClass(); + if (cls.isArray() && "length".equals(property)) { + return Array.getLength(obj); + } try { Field field = cls.getDeclaredField(property); return field.get(obj); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
