[prev in list] [next in list] [prev in thread] [next in thread] 

List:       htmlunit-develop
Subject:    [HtmlUnit] SVN: [11333] branches/htmlunit3/htmlunit/src/main/java/com/gargoylesoftware
From:       asashour () users ! sourceforge ! net
Date:       2015-09-29 15:22:09
Message-ID: E1ZgwjT-00034b-Pq () sfs-ml-3 ! v29 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 11333
          http://sourceforge.net/p/htmlunit/code/11333
Author:   asashour
Date:     2015-09-29 15:22:09 +0000 (Tue, 29 Sep 2015)
Log Message:
-----------
[HU3] fixing build

Modified Paths:
--------------
    branches/htmlunit3/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/NashornJavaScriptEngine.java


Modified: branches/htmlunit3/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/NashornJavaScriptEngine.java
 ===================================================================
--- branches/htmlunit3/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/NashornJavaScriptEngine.java	2015-09-29 \
                13:31:07 UTC (rev 11332)
+++ branches/htmlunit3/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/NashornJavaScriptEngine.java	2015-09-29 \
15:22:09 UTC (rev 11333) @@ -16,6 +16,8 @@
 
 import static com.gargoylesoftware.js.nashorn.internal.objects.annotations.BrowserFamily.CHROME;
  
+import java.lang.reflect.Field;
+
 import javax.script.ScriptContext;
 import javax.script.ScriptEngine;
 import javax.script.SimpleScriptContext;
@@ -64,7 +66,7 @@
     private void initGlobal(final ScriptEngine engine, final Browser browser) {
         Browser.setCurrent(browser);
         final SimpleScriptContext context = (SimpleScriptContext) \
                engine.getContext();
-        final Global global = (Global) ((ScriptObjectMirror) \
context.getBindings(ScriptContext.ENGINE_SCOPE)).getScriptObject(); +        final \
Global global = get(context.getBindings(ScriptContext.ENGINE_SCOPE), "sobj");  final \
Global oldGlobal = Context.getGlobal();  try {
             Context.setGlobal(global);
@@ -94,6 +96,18 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
+    private static <T> T get(final Object o, final String fieldName) {
+        try {
+            final Field field = o.getClass().getDeclaredField(fieldName);
+            field.setAccessible(true);
+            return (T) field.get(o);
+        }
+        catch (final Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
     private void setProto(final Global global, final String childName, final String \
parentName) {  final Object child = global.get(childName);
         if (child instanceof ScriptFunction) {
@@ -141,7 +155,7 @@
     @Override
     public void initialize(final WebWindow webWindow) {
         final SimpleScriptContext context = (SimpleScriptContext) \
                engine.getContext();
-        final Global global = (Global) ((ScriptObjectMirror) \
context.getBindings(ScriptContext.ENGINE_SCOPE)).getScriptObject(); +        final \
Global global = get(context.getBindings(ScriptContext.ENGINE_SCOPE), "sobj");  \
Window2 window2 = (Window2) global.get("window");  window2.initialize(webWindow);
     }


------------------------------------------------------------------------------
_______________________________________________
HtmlUnit-develop mailing list
HtmlUnit-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic