Hi Bryce,
Bryce Ewing schrieb:
Hi all,
Been meaning to write a reply to this for a while. I am confused about
this and was wondering if anyone who has worked on the other scripting
support can explain something. From looking at all the javadocs etc for
javax.script this has all only been around since 1.6, so I am not sure
how the scripting support is supposed to work for sling in 1.5, e.g. the
ScriptContext (which is passed in) says since 1.6 in the javadocs.
Maybe I am missing something obvious as to why this should work (e.g. is
there a library for 1.5 that adds this support?).
You are right, that Java Scripting is only included in the JRE staring
with Java 6 (aka 1.6). For Java 5 (aka 1.5) Sling includes the Apache
BSF 3.0 API library.
Now, the problem is, that the BSF 3.0 library is written for Java 1.4
and up and thus does not use generics. Java Scripting in Java 6 OTOH is
implemented using generics.
So compiling the code on Java 6 without special precautions causes the
use of generics which then leads to problems when running on Java with
BSF 3 containing no generics.
In the scripting/core module we have added special setup in the pom.xml
to ensure compilation with the correct BSF library. See also SLING-217
for details.
Another approach of course is to just compile the bundles with a Java 5 JDK.
Hope this helps.
Regards
Felix