Use fully qualified names when referencing java.lang.Object
authorJaroslav Tulach <jtulach@netbeans.org>
Fri, 15 Jan 2016 11:40:28 +0100
changeset 104136165f49f598
parent 992 6f1a8b251b7d
child 1042 e633fed12064
Use fully qualified names when referencing java.lang.Object
boot/src/test/java/org/netbeans/html/boot/impl/CountFnCreationTest.java
boot/src/test/java/org/netbeans/html/boot/impl/FnTest.java
boot/src/test/java/org/netbeans/html/boot/impl/JavaScriptProcesorTest.java
boot/src/test/java/org/netbeans/html/boot/impl/JsClassLoaderBase.java
boot/src/test/java/org/netbeans/html/boot/impl/JsClassLoaderTest.java
boot/src/test/java/org/netbeans/html/boot/impl/JsMethods.java
boot/src/test/java/org/netbeans/html/boot/impl/KeepAliveTest.java
     1.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/CountFnCreationTest.java	Mon Sep 21 21:19:13 2015 +0200
     1.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/CountFnCreationTest.java	Fri Jan 15 11:40:28 2016 +0100
     1.3 @@ -49,8 +49,6 @@
     1.4  import java.net.URL;
     1.5  import java.util.Collection;
     1.6  import java.util.Enumeration;
     1.7 -import java.util.logging.Level;
     1.8 -import java.util.logging.Logger;
     1.9  import net.java.html.js.JavaScriptBody;
    1.10  import net.java.html.js.JavaScriptResource;
    1.11  import org.netbeans.html.boot.spi.Fn;
    1.12 @@ -118,7 +116,7 @@
    1.13          }
    1.14  
    1.15          @Override
    1.16 -        public Object invoke(Object thiz, Object... args) throws Exception {
    1.17 +        public java.lang.Object invoke(java.lang.Object thiz, java.lang.Object... args) throws Exception {
    1.18              return null;
    1.19          }
    1.20      }
     2.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/FnTest.java	Mon Sep 21 21:19:13 2015 +0200
     2.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/FnTest.java	Fri Jan 15 11:40:28 2016 +0100
     2.3 @@ -106,16 +106,16 @@
     2.4                  sb.append("};");
     2.5                  sb.append("})()");
     2.6                  try {
     2.7 -                    final Object val = eng.eval(sb.toString());
     2.8 +                    final java.lang.Object val = eng.eval(sb.toString());
     2.9                      return new Fn(this) {
    2.10                          @Override
    2.11 -                        public Object invoke(Object thiz, Object... args) throws Exception {
    2.12 -                            List<Object> all = new ArrayList<Object>(args.length + 1);
    2.13 +                        public java.lang.Object invoke(java.lang.Object thiz, java.lang.Object... args) throws Exception {
    2.14 +                            List<java.lang.Object> all = new ArrayList<java.lang.Object>(args.length + 1);
    2.15                              all.add(thiz == null ? val : thiz);
    2.16                              all.addAll(Arrays.asList(args));
    2.17                              Invocable inv = (Invocable)eng;
    2.18                              try {
    2.19 -                                Object ret = inv.invokeMethod(val, "call", all.toArray());
    2.20 +                                java.lang.Object ret = inv.invokeMethod(val, "call", all.toArray());
    2.21                                  return val.equals(ret) ? null : ret;
    2.22                              } catch (ScriptException ex) {
    2.23                                  throw ex;
     3.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/JavaScriptProcesorTest.java	Mon Sep 21 21:19:13 2015 +0200
     3.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/JavaScriptProcesorTest.java	Fri Jan 15 11:40:28 2016 +0100
     3.3 @@ -155,7 +155,7 @@
     3.4      @Test public void generatesCallbacksThatReturnObject() throws Exception {
     3.5          Class<?> callbacksForTestPkg = Class.forName("org.netbeans.html.boot.impl.$JsCallbacks$");
     3.6          Method m = callbacksForTestPkg.getDeclaredMethod("java_lang_Runnable$run$", Runnable.class);
     3.7 -        assertEquals(m.getReturnType(), Object.class, "All methods always return object");
     3.8 +        assertEquals(m.getReturnType(), java.lang.Object.class, "All methods always return object");
     3.9      }
    3.10      
    3.11      @Test public void hasInstanceField() throws Exception {
     4.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/JsClassLoaderBase.java	Mon Sep 21 21:19:13 2015 +0200
     4.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/JsClassLoaderBase.java	Fri Jan 15 11:40:28 2016 +0100
     4.3 @@ -46,8 +46,6 @@
     4.4  import java.lang.reflect.InvocationTargetException;
     4.5  import java.lang.reflect.Method;
     4.6  import java.lang.reflect.Modifier;
     4.7 -import java.util.logging.Level;
     4.8 -import java.util.logging.Logger;
     4.9  import org.netbeans.html.boot.spi.Fn;
    4.10  import org.testng.Assert;
    4.11  import static org.testng.Assert.*;
    4.12 @@ -72,7 +70,7 @@
    4.13      @Test public void noParamMethod() throws Throwable {
    4.14          Method plus = methodClass.getMethod("fortyTwo");
    4.15          try {
    4.16 -            final Object val = plus.invoke(null);
    4.17 +            final java.lang.Object val = plus.invoke(null);
    4.18              assertTrue(val instanceof Number, "A number returned " + val);
    4.19              assertEquals(((Number)val).intValue(), 42);
    4.20          } catch (InvocationTargetException ex) {
    4.21 @@ -100,7 +98,7 @@
    4.22      
    4.23      @Test public void instanceMethod() throws Throwable {
    4.24          Method plus = methodClass.getMethod("plusInst", int.class);
    4.25 -        Object inst = methodClass.newInstance();
    4.26 +        java.lang.Object inst = methodClass.newInstance();
    4.27          try {
    4.28              assertEquals(plus.invoke(inst, 10), 10);
    4.29          } catch (InvocationTargetException ex) {
    4.30 @@ -118,7 +116,7 @@
    4.31      }
    4.32  
    4.33      @Test public void getThis() throws Throwable {
    4.34 -        Object th = methodClass.newInstance();
    4.35 +        java.lang.Object th = methodClass.newInstance();
    4.36          Method st = methodClass.getMethod("getThis");
    4.37          try {
    4.38              assertEquals(st.invoke(th), th);
    4.39 @@ -166,7 +164,7 @@
    4.40      
    4.41      @Test public void callJavaScriptMethodOnOwnClass() throws Throwable {
    4.42          try {
    4.43 -            Object thiz = methodClass.newInstance();
    4.44 +            java.lang.Object thiz = methodClass.newInstance();
    4.45              Method st = methodClass.getMethod("returnYourSelf", methodClass);
    4.46              assertEquals(st.invoke(null, thiz), thiz, "Returns this");
    4.47          } catch (InvocationTargetException ex) {
    4.48 @@ -190,7 +188,7 @@
    4.49          Class<? extends Enum> enmClazz2 = enmClazz.asSubclass(Enum.class);
    4.50          Method st = methodClass.getMethod("fromEnum", enmClazz);
    4.51          
    4.52 -        Object valueB = Enum.valueOf(enmClazz2, "B");
    4.53 +        java.lang.Object valueB = Enum.valueOf(enmClazz2, "B");
    4.54          assertEquals(st.invoke(null, valueB), "B", "Converts to string");
    4.55      }
    4.56      
    4.57 @@ -210,7 +208,7 @@
    4.58      }
    4.59      
    4.60      @Test public void recordError() throws Throwable {
    4.61 -        Method st = methodClass.getMethod("recordError", Object.class);
    4.62 +        Method st = methodClass.getMethod("recordError", java.lang.Object.class);
    4.63          assertEquals(st.invoke(methodClass.newInstance(), "Hello"), "Hello", "The same parameter returned");
    4.64      }
    4.65      
    4.66 @@ -239,10 +237,10 @@
    4.67      
    4.68      @Test public void arrayInOut() throws Throwable {
    4.69          String[] arr = { "Ahoj" };
    4.70 -        Method st = methodClass.getMethod("arr", Object[].class);
    4.71 -        Object ret = st.invoke(null, (Object) arr);
    4.72 -        assertTrue(ret instanceof Object[], "Expecting array: " + ret);
    4.73 -        Object[] res = (Object[]) ret;
    4.74 +        Method st = methodClass.getMethod("arr", java.lang.Object[].class);
    4.75 +        java.lang.Object ret = st.invoke(null, (java.lang.Object) arr);
    4.76 +        assertTrue(ret instanceof java.lang.Object[], "Expecting array: " + ret);
    4.77 +        java.lang.Object[] res = (java.lang.Object[]) ret;
    4.78          assertEquals(res.length, 1, "One element");
    4.79          assertEquals(res[0], "Ahoj", "The right string");
    4.80      }
    4.81 @@ -250,7 +248,7 @@
    4.82     @Test public void checkTheTypeOfThrownException() throws Throwable {
    4.83          FnContext.currentPresenter(null);
    4.84          assertNull(Fn.activePresenter(), "No presenter is activer right now");
    4.85 -        Object res = null;
    4.86 +        java.lang.Object res = null;
    4.87          try {
    4.88              Method st = methodClass.getMethod("plus", int.class, int.class);
    4.89              try {
     5.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/JsClassLoaderTest.java	Mon Sep 21 21:19:13 2015 +0200
     5.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/JsClassLoaderTest.java	Fri Jan 15 11:40:28 2016 +0100
     5.3 @@ -44,7 +44,6 @@
     5.4  
     5.5  import java.io.Closeable;
     5.6  import java.io.Reader;
     5.7 -import org.netbeans.html.boot.spi.Fn;
     5.8  import java.net.URL;
     5.9  import java.net.URLClassLoader;
    5.10  import java.util.ArrayList;
    5.11 @@ -56,6 +55,7 @@
    5.12  import javax.script.ScriptEngine;
    5.13  import javax.script.ScriptEngineManager;
    5.14  import javax.script.ScriptException;
    5.15 +import org.netbeans.html.boot.spi.Fn;
    5.16  import org.testng.annotations.AfterClass;
    5.17  import org.testng.annotations.BeforeClass;
    5.18  import org.testng.annotations.BeforeMethod;
    5.19 @@ -101,16 +101,16 @@
    5.20                  sb.append("};");
    5.21                  sb.append("})()");
    5.22                  try {
    5.23 -                    final Object val = eng.eval(sb.toString());
    5.24 +                    final java.lang.Object val = eng.eval(sb.toString());
    5.25                      return new Fn(this) {
    5.26                          @Override
    5.27 -                        public Object invoke(Object thiz, Object... args) throws Exception {
    5.28 -                            List<Object> all = new ArrayList<Object>(args.length + 1);
    5.29 +                        public java.lang.Object invoke(java.lang.Object thiz, java.lang.Object... args) throws Exception {
    5.30 +                            List<java.lang.Object> all = new ArrayList<java.lang.Object>(args.length + 1);
    5.31                              all.add(thiz == null ? val : thiz);
    5.32                              all.addAll(Arrays.asList(args));
    5.33                              Invocable inv = (Invocable)eng;
    5.34                              try {
    5.35 -                                Object ret = inv.invokeMethod(val, "call", all.toArray());
    5.36 +                                java.lang.Object ret = inv.invokeMethod(val, "call", all.toArray());
    5.37                                  return val.equals(ret) ? null : ret;
    5.38                              } catch (Exception ex) {
    5.39                                  throw ex;
     6.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/JsMethods.java	Mon Sep 21 21:19:13 2015 +0200
     6.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/JsMethods.java	Fri Jan 15 11:40:28 2016 +0100
     6.3 @@ -52,10 +52,10 @@
     6.4   */
     6.5  @JavaScriptResource("jsmethods.js")
     6.6  public class JsMethods {
     6.7 -    private Object value;
     6.8 +    private java.lang.Object value;
     6.9      
    6.10      @JavaScriptBody(args = {}, body = "return 42;")
    6.11 -    public static Object fortyTwo() {
    6.12 +    public static java.lang.Object fortyTwo() {
    6.13          return -42;
    6.14      }
    6.15      
    6.16 @@ -66,10 +66,10 @@
    6.17      public static native int plus(int x);
    6.18      
    6.19      @JavaScriptBody(args = {}, body = "return this;")
    6.20 -    public static native Object staticThis();
    6.21 +    public static native java.lang.Object staticThis();
    6.22      
    6.23      @JavaScriptBody(args = {}, body = "return this;")
    6.24 -    public native Object getThis();
    6.25 +    public native java.lang.Object getThis();
    6.26      @JavaScriptBody(args = {"x"}, body = "return x;")
    6.27      public native int plusInst(int x);
    6.28      
    6.29 @@ -110,7 +110,7 @@
    6.30      public static native String fromEnum(Enm v);
    6.31      
    6.32      @JavaScriptBody(args = "arr", body = "return arr;")
    6.33 -    public static native Object[] arr(Object[] arr);
    6.34 +    public static native java.lang.Object[] arr(java.lang.Object[] arr);
    6.35      
    6.36      @JavaScriptBody(args = { "useA", "useB", "a", "b" }, body = "var l = 0;"
    6.37          + "if (useA) l += a;\n"
    6.38 @@ -119,11 +119,11 @@
    6.39      )
    6.40      public static native long chooseLong(boolean useA, boolean useB, long a, long b);
    6.41      
    6.42 -    protected void onError(Object o) throws Exception {
    6.43 +    protected void onError(java.lang.Object o) throws Exception {
    6.44          value = o;
    6.45      }
    6.46      
    6.47 -    Object getError() {
    6.48 +    java.lang.Object getError() {
    6.49          return value;
    6.50      }
    6.51      
    6.52 @@ -131,7 +131,7 @@
    6.53          "this.@org.netbeans.html.boot.impl.JsMethods::onError(Ljava/lang/Object;)(err);"
    6.54        + "return this.@org.netbeans.html.boot.impl.JsMethods::getError()();"
    6.55      )
    6.56 -    public native Object recordError(Object err);
    6.57 +    public native java.lang.Object recordError(java.lang.Object err);
    6.58      
    6.59      @JavaScriptBody(args = { "x", "y" }, body = "return x + y;")
    6.60      public static int plusOrMul(int x, int y) {
    6.61 @@ -139,7 +139,7 @@
    6.62      }
    6.63      
    6.64      @JavaScriptBody(args = { "x" }, keepAlive = false, body = "throw 'Do not call me!'")
    6.65 -    public static native int checkAllowGC(Object x);
    6.66 +    public static native int checkAllowGC(java.lang.Object x);
    6.67      
    6.68      enum Enm {
    6.69          A, B;
     7.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/KeepAliveTest.java	Mon Sep 21 21:19:13 2015 +0200
     7.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/KeepAliveTest.java	Fri Jan 15 11:40:28 2016 +0100
     7.3 @@ -48,8 +48,6 @@
     7.4  import java.util.Collection;
     7.5  import org.netbeans.html.boot.spi.Fn;
     7.6  import static org.testng.Assert.assertEquals;
     7.7 -import static org.testng.Assert.assertFalse;
     7.8 -import static org.testng.Assert.assertTrue;
     7.9  import org.testng.annotations.BeforeMethod;
    7.10  import org.testng.annotations.Test;
    7.11  
    7.12 @@ -57,7 +55,7 @@
    7.13      private Class<?> jsMethods;
    7.14      @Test public void keepAliveIsSetToFalse() throws Exception {
    7.15          Closeable c = Fn.activate(this);
    7.16 -        Number ret = (Number)jsMethods.getMethod("checkAllowGC", Object.class).invoke(null, this);
    7.17 +        Number ret = (Number)jsMethods.getMethod("checkAllowGC", java.lang.Object.class).invoke(null, this);
    7.18          c.close();
    7.19          assertEquals(ret.intValue(), 0, "keepAlive is set to false");
    7.20      }    
    7.21 @@ -79,7 +77,7 @@
    7.22      public Fn defineFn(String code, String[] names, final boolean[] keepAlive) {
    7.23          return new Fn(this) {
    7.24              @Override
    7.25 -            public Object invoke(Object thiz, Object... args) throws Exception {
    7.26 +            public java.lang.Object invoke(java.lang.Object thiz, java.lang.Object... args) throws Exception {
    7.27                  boolean res = true;
    7.28                  if (keepAlive != null) {
    7.29                      for (int i = 0; i < keepAlive.length; i++) {