You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by en...@apache.org on 2021/08/07 21:08:00 UTC

[sling-org-apache-sling-scripting-sightly] branch master updated: SLING-10677 add support for using an enum class via the Java Use-API (#13)

This is an automated email from the ASF dual-hosted git repository.

enorman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e1965c  SLING-10677 add support for using an enum class via the Java Use-API (#13)
8e1965c is described below

commit 8e1965cc1285eb16b79ee018b061200f43aeb596
Author: Eric Norman <er...@gmail.com>
AuthorDate: Sat Aug 7 14:07:57 2021 -0700

    SLING-10677 add support for using an enum class via the Java Use-API (#13)
---
 pom.xml                                                                | 2 +-
 .../scripting/sightly/impl/engine/extension/use/JavaUseProvider.java   | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 766d643..a1bb598 100644
--- a/pom.xml
+++ b/pom.xml
@@ -147,7 +147,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.sightly.runtime</artifactId>
-            <version>1.2.4-1.4.0</version>
+            <version>1.2.6-1.4.0</version>
             <scope>provided</scope>
         </dependency>
 
diff --git a/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java b/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java
index 28560d6..c1f70cd 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java
@@ -214,6 +214,9 @@ public class JavaUseProvider implements UseProvider {
                 LOG.debug("Won't attempt to instantiate an interface or abstract class {}", cls.getName());
                 return ProviderOutcome.failure(new IllegalArgumentException(String.format(" %s represents an interface or an abstract " +
                         "class which cannot be instantiated.", cls.getName())));
+            } else if (cls.isEnum()) {
+                // for enum, just return the class
+                return ProviderOutcome.success(cls);
             } else {
                 /*
                  * the object was cached by the class loader but it's not adaptable from {@link Resource} or {@link