Debian Codegraph @

debian/patches/0001-Always-use-internal-JavaScript-engine.patch

raw
1 From: =?utf-8?q?Timo_R=C3=B6hling?= <[email protected]>
2 Date: Fri, 19 Apr 2024 13:04:59 +0200
3 Subject: Always use internal JavaScript engine
4
5 As long as the Nashorn engine is not packaged for Debian, this package
6 will only work with OpenJDK < 14.
7
8 Forwarded: not-needed
9 ---
10 .../java/com/eprosima/idl/context/Context.java | 29 +++++++++++++++-------
11 1 file changed, 20 insertions(+), 9 deletions(-)
12
13 diff --git a/src/main/java/com/eprosima/idl/context/Context.java b/src/main/java/com/eprosima/idl/context/Context.java
14 index 1cb2808..39c575b 100644
15 --- a/src/main/java/com/eprosima/idl/context/Context.java
16 +++ b/src/main/java/com/eprosima/idl/context/Context.java
17 @@ -1439,15 +1439,7 @@ public class Context
18
19 public static ScriptEngine getJSScriptEngine()
20 {
21 - if (Double.parseDouble(System.getProperty("java.specification.version")) < 11)
22 - {
23 - return new ScriptEngineManager().getEngineByName("js");
24 - }
25 - else
26 - {
27 - return new org.openjdk.nashorn.api.scripting.NashornScriptEngineFactory()
28 - .getScriptEngine();
29 - }
30 + return new ScriptEngineManager().getEngineByName("js");
31 }
32
33 public String evaluate_literal(
34 @@ -1490,6 +1482,25 @@ public class Context
35 try
36 {
37 ScriptEngine engine = getJSScriptEngine();
38 + if (engine == null)
39 + {
40 + // Fallback for simple expressions
41 + for (Definition definition : m_definitions)
42 + {
43 + if (definition.isIsConstDeclaration())
44 + {
45 + ConstDeclaration const_decl = (ConstDeclaration)definition;
46 + if (const_decl.getTypeCode().isPrimitive() || const_decl.getTypeCode().isIsStringType() || const_decl.getTypeCode().isIsWStringType())
47 + {
48 + if (str == const_decl.getScopedname())
49 + return const_decl.getValue();
50 + if (const_decl.getScope() == getScope() && str == const_decl.getName())
51 + return const_decl.getValue();
52 + }
53 + }
54 + }
55 + return str;
56 + }
57 aux_str = engine.eval(aux_str).toString();
58 }
59 catch (ScriptException se)