Make sure this has some value
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 07 Jan 2013 17:22:59 +0100
changeset 412777b9b841f15
parent 411 6506d5132e03
child 413 c91483c86597
Make sure this has some value
launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java
vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java
vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java
     1.1 --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java	Mon Jan 07 16:46:09 2013 +0100
     1.2 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java	Mon Jan 07 17:22:59 2013 +0100
     1.3 @@ -21,9 +21,8 @@
     1.4  import java.io.InputStream;
     1.5  import java.lang.reflect.InvocationTargetException;
     1.6  import java.lang.reflect.Method;
     1.7 +import java.lang.reflect.Modifier;
     1.8  import java.net.URL;
     1.9 -import java.net.URLDecoder;
    1.10 -import java.net.URLEncoder;
    1.11  import java.util.Enumeration;
    1.12  import org.apidesign.bck2brwsr.core.JavaScriptBody;
    1.13  
    1.14 @@ -113,7 +112,7 @@
    1.15          return sb.toString();
    1.16      }
    1.17      
    1.18 -    static String invoke(String clazz, String method) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException {
    1.19 +    static String invoke(String clazz, String method) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException, InstantiationException {
    1.20          final Object r = invokeMethod(clazz, method);
    1.21          return r == null ? "null" : r.toString().toString();
    1.22      }
    1.23 @@ -151,7 +150,8 @@
    1.24     
    1.25      private static Object invokeMethod(String clazz, String method) 
    1.26      throws ClassNotFoundException, InvocationTargetException, 
    1.27 -    SecurityException, IllegalAccessException, IllegalArgumentException {
    1.28 +    SecurityException, IllegalAccessException, IllegalArgumentException,
    1.29 +    InstantiationException {
    1.30          Method found = null;
    1.31          Class<?> c = Class.forName(clazz);
    1.32          for (Method m : c.getMethods()) {
    1.33 @@ -161,7 +161,11 @@
    1.34          }
    1.35          Object res;
    1.36          if (found != null) {
    1.37 -            res = found.invoke(null);
    1.38 +            if ((found.getModifiers() & Modifier.STATIC) != 0) {
    1.39 +                res = found.invoke(null);
    1.40 +            } else {
    1.41 +                res = found.invoke(c.newInstance());
    1.42 +            }
    1.43          } else {
    1.44              res = "Can't find method " + method + " in " + clazz;
    1.45          }
     2.1 --- a/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java	Mon Jan 07 16:46:09 2013 +0100
     2.2 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java	Mon Jan 07 17:22:59 2013 +0100
     2.3 @@ -30,7 +30,7 @@
     2.4      
     2.5      @Compare public Object notSupported() {
     2.6          try {
     2.7 -            return new CloneTest().clone();
     2.8 +            return this.clone();
     2.9          } catch (CloneNotSupportedException ex) {
    2.10              return ex.getClass().getName() + ":" + ex.getMessage();
    2.11          }
    2.12 @@ -46,7 +46,7 @@
    2.13      }
    2.14  
    2.15      @Compare public int sameReference() throws CloneNotSupportedException {
    2.16 -        CloneTest self = new CloneTest();
    2.17 +        CloneTest self = this;
    2.18          Clnbl orig = new Clnbl();
    2.19          self.value = 33;
    2.20          orig.ref = self;
     3.1 --- a/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java	Mon Jan 07 16:46:09 2013 +0100
     3.2 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java	Mon Jan 07 17:22:59 2013 +0100
     3.3 @@ -21,8 +21,6 @@
     3.4  import java.util.Arrays;
     3.5  import java.util.Collections;
     3.6  import java.util.List;
     3.7 -import java.util.logging.Level;
     3.8 -import java.util.logging.Logger;
     3.9  import org.apidesign.bck2brwsr.core.JavaScriptBody;
    3.10  import org.apidesign.bck2brwsr.vmtest.Compare;
    3.11  import org.apidesign.bck2brwsr.vmtest.VMTest;
    3.12 @@ -33,6 +31,10 @@
    3.13   * @author Jaroslav Tulach <jtulach@netbeans.org>
    3.14   */
    3.15  public class ReflectionTest {
    3.16 +    @Compare public boolean nonNullThis() {
    3.17 +        return this == null;
    3.18 +    }
    3.19 +    
    3.20      @Compare public String intType() {
    3.21          return Integer.TYPE.toString();
    3.22      }