1.1 --- a/boot/src/main/java/org/netbeans/html/boot/impl/JavaScriptProcesor.java Wed Jan 13 05:53:12 2016 +0100
1.2 +++ b/boot/src/main/java/org/netbeans/html/boot/impl/JavaScriptProcesor.java Fri Jan 15 13:08:35 2016 +0100
1.3 @@ -72,10 +72,10 @@
1.4 import javax.lang.model.element.TypeElement;
1.5 import javax.lang.model.element.VariableElement;
1.6 import javax.lang.model.type.ArrayType;
1.7 -import javax.lang.model.type.DeclaredType;
1.8 import javax.lang.model.type.ExecutableType;
1.9 import javax.lang.model.type.TypeKind;
1.10 import javax.lang.model.type.TypeMirror;
1.11 +import javax.lang.model.util.Types;
1.12 import javax.tools.Diagnostic;
1.13 import javax.tools.FileObject;
1.14 import javax.tools.StandardLocation;
1.15 @@ -302,7 +302,8 @@
1.16 tm = ((ArrayType)tm).getComponentType();
1.17 }
1.18 sb.append('L');
1.19 - Element elm = processingEnv.getTypeUtils().asElement(tm);
1.20 + Types tu = processingEnv.getTypeUtils();
1.21 + Element elm = tu.asElement(tu.erasure(tm));
1.22 dumpElems(sb, elm, ';');
1.23 }
1.24 }
1.25 @@ -414,7 +415,7 @@
1.26 return;
1.27 }
1.28 final TypeElement selfType = (TypeElement)m.getEnclosingElement();
1.29 -
1.30 + Types tu = processingEnv.getTypeUtils();
1.31
1.32 source.append("\n public java.lang.Object ")
1.33 .append(mangled)
1.34 @@ -424,7 +425,7 @@
1.35 StringBuilder convert = new StringBuilder();
1.36 if (!isStatic) {
1.37 if (selfObj) {
1.38 - source.append("Object self");
1.39 + source.append("java.lang.Object self");
1.40 convert.append(" if (p instanceof org.netbeans.html.boot.spi.Fn.FromJavaScript) {\n");
1.41 convert.append(" self").
1.42 append(" = ((org.netbeans.html.boot.spi.Fn.FromJavaScript)p).toJava(self").
1.43 @@ -443,7 +444,7 @@
1.44 ++cnt;
1.45 final TypeMirror t = ve.asType();
1.46 if (!t.getKind().isPrimitive() && !"java.lang.String".equals(t.toString())) { // NOI18N
1.47 - source.append("Object");
1.48 + source.append("java.lang.Object");
1.49 convert.append(" if (p instanceof org.netbeans.html.boot.spi.Fn.FromJavaScript) {\n");
1.50 convert.append(" arg").append(cnt).
1.51 append(" = ((org.netbeans.html.boot.spi.Fn.FromJavaScript)p).toJava(arg").append(cnt).
1.52 @@ -464,7 +465,7 @@
1.53 }
1.54 source.append(" ");
1.55 if (m.getReturnType().getKind() != TypeKind.VOID) {
1.56 - source.append("Object $ret = ");
1.57 + source.append("java.lang.Object $ret = ");
1.58 }
1.59 if (isStatic) {
1.60 source.append(((TypeElement)m.getEnclosingElement()).getQualifiedName());
1.61 @@ -484,7 +485,7 @@
1.62 sep = "";
1.63 for (VariableElement ve : m.getParameters()) {
1.64 source.append(sep);
1.65 - source.append("(").append(ve.asType());
1.66 + source.append("(").append(tu.erasure(ve.asType()));
1.67 source.append(")arg").append(++cnt);
1.68 sep = ", ";
1.69 }
2.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/CountFnCreationTest.java Wed Jan 13 05:53:12 2016 +0100
2.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/CountFnCreationTest.java Fri Jan 15 13:08:35 2016 +0100
2.3 @@ -49,8 +49,6 @@
2.4 import java.net.URL;
2.5 import java.util.Collection;
2.6 import java.util.Enumeration;
2.7 -import java.util.logging.Level;
2.8 -import java.util.logging.Logger;
2.9 import net.java.html.js.JavaScriptBody;
2.10 import net.java.html.js.JavaScriptResource;
2.11 import org.netbeans.html.boot.spi.Fn;
2.12 @@ -118,7 +116,7 @@
2.13 }
2.14
2.15 @Override
2.16 - public Object invoke(Object thiz, Object... args) throws Exception {
2.17 + public java.lang.Object invoke(java.lang.Object thiz, java.lang.Object... args) throws Exception {
2.18 return null;
2.19 }
2.20 }
3.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/FnTest.java Wed Jan 13 05:53:12 2016 +0100
3.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/FnTest.java Fri Jan 15 13:08:35 2016 +0100
3.3 @@ -106,16 +106,16 @@
3.4 sb.append("};");
3.5 sb.append("})()");
3.6 try {
3.7 - final Object val = eng.eval(sb.toString());
3.8 + final java.lang.Object val = eng.eval(sb.toString());
3.9 return new Fn(this) {
3.10 @Override
3.11 - public Object invoke(Object thiz, Object... args) throws Exception {
3.12 - List<Object> all = new ArrayList<Object>(args.length + 1);
3.13 + public java.lang.Object invoke(java.lang.Object thiz, java.lang.Object... args) throws Exception {
3.14 + List<java.lang.Object> all = new ArrayList<java.lang.Object>(args.length + 1);
3.15 all.add(thiz == null ? val : thiz);
3.16 all.addAll(Arrays.asList(args));
3.17 Invocable inv = (Invocable)eng;
3.18 try {
3.19 - Object ret = inv.invokeMethod(val, "call", all.toArray());
3.20 + java.lang.Object ret = inv.invokeMethod(val, "call", all.toArray());
3.21 return val.equals(ret) ? null : ret;
3.22 } catch (ScriptException ex) {
3.23 throw ex;
4.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/JavaScriptProcesorTest.java Wed Jan 13 05:53:12 2016 +0100
4.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/JavaScriptProcesorTest.java Fri Jan 15 13:08:35 2016 +0100
4.3 @@ -155,7 +155,7 @@
4.4 @Test public void generatesCallbacksThatReturnObject() throws Exception {
4.5 Class<?> callbacksForTestPkg = Class.forName("org.netbeans.html.boot.impl.$JsCallbacks$");
4.6 Method m = callbacksForTestPkg.getDeclaredMethod("java_lang_Runnable$run$", Runnable.class);
4.7 - assertEquals(m.getReturnType(), Object.class, "All methods always return object");
4.8 + assertEquals(m.getReturnType(), java.lang.Object.class, "All methods always return object");
4.9 }
4.10
4.11 @Test public void hasInstanceField() throws Exception {
5.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/JsClassLoaderBase.java Wed Jan 13 05:53:12 2016 +0100
5.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/JsClassLoaderBase.java Fri Jan 15 13:08:35 2016 +0100
5.3 @@ -46,8 +46,8 @@
5.4 import java.lang.reflect.InvocationTargetException;
5.5 import java.lang.reflect.Method;
5.6 import java.lang.reflect.Modifier;
5.7 -import java.util.logging.Level;
5.8 -import java.util.logging.Logger;
5.9 +import java.util.HashMap;
5.10 +import java.util.Map;
5.11 import org.netbeans.html.boot.spi.Fn;
5.12 import org.testng.Assert;
5.13 import static org.testng.Assert.*;
5.14 @@ -72,7 +72,7 @@
5.15 @Test public void noParamMethod() throws Throwable {
5.16 Method plus = methodClass.getMethod("fortyTwo");
5.17 try {
5.18 - final Object val = plus.invoke(null);
5.19 + final java.lang.Object val = plus.invoke(null);
5.20 assertTrue(val instanceof Number, "A number returned " + val);
5.21 assertEquals(((Number)val).intValue(), 42);
5.22 } catch (InvocationTargetException ex) {
5.23 @@ -100,7 +100,7 @@
5.24
5.25 @Test public void instanceMethod() throws Throwable {
5.26 Method plus = methodClass.getMethod("plusInst", int.class);
5.27 - Object inst = methodClass.newInstance();
5.28 + java.lang.Object inst = methodClass.newInstance();
5.29 try {
5.30 assertEquals(plus.invoke(inst, 10), 10);
5.31 } catch (InvocationTargetException ex) {
5.32 @@ -118,7 +118,7 @@
5.33 }
5.34
5.35 @Test public void getThis() throws Throwable {
5.36 - Object th = methodClass.newInstance();
5.37 + java.lang.Object th = methodClass.newInstance();
5.38 Method st = methodClass.getMethod("getThis");
5.39 try {
5.40 assertEquals(st.invoke(th), th);
5.41 @@ -166,7 +166,7 @@
5.42
5.43 @Test public void callJavaScriptMethodOnOwnClass() throws Throwable {
5.44 try {
5.45 - Object thiz = methodClass.newInstance();
5.46 + java.lang.Object thiz = methodClass.newInstance();
5.47 Method st = methodClass.getMethod("returnYourSelf", methodClass);
5.48 assertEquals(st.invoke(null, thiz), thiz, "Returns this");
5.49 } catch (InvocationTargetException ex) {
5.50 @@ -190,7 +190,7 @@
5.51 Class<? extends Enum> enmClazz2 = enmClazz.asSubclass(Enum.class);
5.52 Method st = methodClass.getMethod("fromEnum", enmClazz);
5.53
5.54 - Object valueB = Enum.valueOf(enmClazz2, "B");
5.55 + java.lang.Object valueB = Enum.valueOf(enmClazz2, "B");
5.56 assertEquals(st.invoke(null, valueB), "B", "Converts to string");
5.57 }
5.58
5.59 @@ -210,7 +210,7 @@
5.60 }
5.61
5.62 @Test public void recordError() throws Throwable {
5.63 - Method st = methodClass.getMethod("recordError", Object.class);
5.64 + Method st = methodClass.getMethod("recordError", java.lang.Object.class);
5.65 assertEquals(st.invoke(methodClass.newInstance(), "Hello"), "Hello", "The same parameter returned");
5.66 }
5.67
5.68 @@ -239,18 +239,25 @@
5.69
5.70 @Test public void arrayInOut() throws Throwable {
5.71 String[] arr = { "Ahoj" };
5.72 - Method st = methodClass.getMethod("arr", Object[].class);
5.73 - Object ret = st.invoke(null, (Object) arr);
5.74 - assertTrue(ret instanceof Object[], "Expecting array: " + ret);
5.75 - Object[] res = (Object[]) ret;
5.76 + Method st = methodClass.getMethod("arr", java.lang.Object[].class);
5.77 + java.lang.Object ret = st.invoke(null, (java.lang.Object) arr);
5.78 + assertTrue(ret instanceof java.lang.Object[], "Expecting array: " + ret);
5.79 + java.lang.Object[] res = (java.lang.Object[]) ret;
5.80 assertEquals(res.length, 1, "One element");
5.81 assertEquals(res[0], "Ahoj", "The right string");
5.82 }
5.83 +
5.84 + @Test public void parametricCallback() throws Throwable {
5.85 + Map<String,Integer> map = new HashMap<String, Integer>();
5.86 + Method st = methodClass.getMethod("callParamTypes", Map.class, int.class);
5.87 + st.invoke(null, map, 42);
5.88 + assertEquals(map.get("key"), Integer.valueOf(42), "The right value");
5.89 + }
5.90
5.91 @Test public void checkTheTypeOfThrownException() throws Throwable {
5.92 FnContext.currentPresenter(null);
5.93 assertNull(Fn.activePresenter(), "No presenter is activer right now");
5.94 - Object res = null;
5.95 + java.lang.Object res = null;
5.96 try {
5.97 Method st = methodClass.getMethod("plus", int.class, int.class);
5.98 try {
6.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/JsClassLoaderTest.java Wed Jan 13 05:53:12 2016 +0100
6.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/JsClassLoaderTest.java Fri Jan 15 13:08:35 2016 +0100
6.3 @@ -44,7 +44,6 @@
6.4
6.5 import java.io.Closeable;
6.6 import java.io.Reader;
6.7 -import org.netbeans.html.boot.spi.Fn;
6.8 import java.net.URL;
6.9 import java.net.URLClassLoader;
6.10 import java.util.ArrayList;
6.11 @@ -56,6 +55,7 @@
6.12 import javax.script.ScriptEngine;
6.13 import javax.script.ScriptEngineManager;
6.14 import javax.script.ScriptException;
6.15 +import org.netbeans.html.boot.spi.Fn;
6.16 import org.testng.annotations.AfterClass;
6.17 import org.testng.annotations.BeforeClass;
6.18 import org.testng.annotations.BeforeMethod;
6.19 @@ -101,16 +101,16 @@
6.20 sb.append("};");
6.21 sb.append("})()");
6.22 try {
6.23 - final Object val = eng.eval(sb.toString());
6.24 + final java.lang.Object val = eng.eval(sb.toString());
6.25 return new Fn(this) {
6.26 @Override
6.27 - public Object invoke(Object thiz, Object... args) throws Exception {
6.28 - List<Object> all = new ArrayList<Object>(args.length + 1);
6.29 + public java.lang.Object invoke(java.lang.Object thiz, java.lang.Object... args) throws Exception {
6.30 + List<java.lang.Object> all = new ArrayList<java.lang.Object>(args.length + 1);
6.31 all.add(thiz == null ? val : thiz);
6.32 all.addAll(Arrays.asList(args));
6.33 Invocable inv = (Invocable)eng;
6.34 try {
6.35 - Object ret = inv.invokeMethod(val, "call", all.toArray());
6.36 + java.lang.Object ret = inv.invokeMethod(val, "call", all.toArray());
6.37 return val.equals(ret) ? null : ret;
6.38 } catch (Exception ex) {
6.39 throw ex;
7.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/JsMethods.java Wed Jan 13 05:53:12 2016 +0100
7.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/JsMethods.java Fri Jan 15 13:08:35 2016 +0100
7.3 @@ -42,6 +42,7 @@
7.4 */
7.5 package org.netbeans.html.boot.impl;
7.6
7.7 +import java.util.Map;
7.8 import net.java.html.js.JavaScriptBody;
7.9 import net.java.html.js.JavaScriptResource;
7.10
7.11 @@ -52,10 +53,10 @@
7.12 */
7.13 @JavaScriptResource("jsmethods.js")
7.14 public class JsMethods {
7.15 - private Object value;
7.16 + private java.lang.Object value;
7.17
7.18 @JavaScriptBody(args = {}, body = "return 42;")
7.19 - public static Object fortyTwo() {
7.20 + public static java.lang.Object fortyTwo() {
7.21 return -42;
7.22 }
7.23
7.24 @@ -66,10 +67,10 @@
7.25 public static native int plus(int x);
7.26
7.27 @JavaScriptBody(args = {}, body = "return this;")
7.28 - public static native Object staticThis();
7.29 + public static native java.lang.Object staticThis();
7.30
7.31 @JavaScriptBody(args = {}, body = "return this;")
7.32 - public native Object getThis();
7.33 + public native java.lang.Object getThis();
7.34 @JavaScriptBody(args = {"x"}, body = "return x;")
7.35 public native int plusInst(int x);
7.36
7.37 @@ -110,7 +111,7 @@
7.38 public static native String fromEnum(Enm v);
7.39
7.40 @JavaScriptBody(args = "arr", body = "return arr;")
7.41 - public static native Object[] arr(Object[] arr);
7.42 + public static native java.lang.Object[] arr(java.lang.Object[] arr);
7.43
7.44 @JavaScriptBody(args = { "useA", "useB", "a", "b" }, body = "var l = 0;"
7.45 + "if (useA) l += a;\n"
7.46 @@ -119,11 +120,11 @@
7.47 )
7.48 public static native long chooseLong(boolean useA, boolean useB, long a, long b);
7.49
7.50 - protected void onError(Object o) throws Exception {
7.51 + protected void onError(java.lang.Object o) throws Exception {
7.52 value = o;
7.53 }
7.54
7.55 - Object getError() {
7.56 + java.lang.Object getError() {
7.57 return value;
7.58 }
7.59
7.60 @@ -131,7 +132,7 @@
7.61 "this.@org.netbeans.html.boot.impl.JsMethods::onError(Ljava/lang/Object;)(err);"
7.62 + "return this.@org.netbeans.html.boot.impl.JsMethods::getError()();"
7.63 )
7.64 - public native Object recordError(Object err);
7.65 + public native java.lang.Object recordError(java.lang.Object err);
7.66
7.67 @JavaScriptBody(args = { "x", "y" }, body = "return x + y;")
7.68 public static int plusOrMul(int x, int y) {
7.69 @@ -139,9 +140,15 @@
7.70 }
7.71
7.72 @JavaScriptBody(args = { "x" }, keepAlive = false, body = "throw 'Do not call me!'")
7.73 - public static native int checkAllowGC(Object x);
7.74 + public static native int checkAllowGC(java.lang.Object x);
7.75 +
7.76 + @JavaScriptBody(args = { "map", "value" }, javacall = true, body =
7.77 + "map.@java.util.Map::put(Ljava/lang/Object;Ljava/lang/Object;)('key',value);"
7.78 + )
7.79 + public static native void callParamTypes(Map<String,Integer> map, int value);
7.80
7.81 enum Enm {
7.82 A, B;
7.83 }
7.84 }
7.85 +
8.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/KeepAliveTest.java Wed Jan 13 05:53:12 2016 +0100
8.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/KeepAliveTest.java Fri Jan 15 13:08:35 2016 +0100
8.3 @@ -48,8 +48,6 @@
8.4 import java.util.Collection;
8.5 import org.netbeans.html.boot.spi.Fn;
8.6 import static org.testng.Assert.assertEquals;
8.7 -import static org.testng.Assert.assertFalse;
8.8 -import static org.testng.Assert.assertTrue;
8.9 import org.testng.annotations.BeforeMethod;
8.10 import org.testng.annotations.Test;
8.11
8.12 @@ -57,7 +55,7 @@
8.13 private Class<?> jsMethods;
8.14 @Test public void keepAliveIsSetToFalse() throws Exception {
8.15 Closeable c = Fn.activate(this);
8.16 - Number ret = (Number)jsMethods.getMethod("checkAllowGC", Object.class).invoke(null, this);
8.17 + Number ret = (Number)jsMethods.getMethod("checkAllowGC", java.lang.Object.class).invoke(null, this);
8.18 c.close();
8.19 assertEquals(ret.intValue(), 0, "keepAlive is set to false");
8.20 }
8.21 @@ -79,7 +77,7 @@
8.22 public Fn defineFn(String code, String[] names, final boolean[] keepAlive) {
8.23 return new Fn(this) {
8.24 @Override
8.25 - public Object invoke(Object thiz, Object... args) throws Exception {
8.26 + public java.lang.Object invoke(java.lang.Object thiz, java.lang.Object... args) throws Exception {
8.27 boolean res = true;
8.28 if (keepAlive != null) {
8.29 for (int i = 0; i < keepAlive.length; i++) {
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/Object.java Fri Jan 15 13:08:35 2016 +0100
9.3 @@ -0,0 +1,49 @@
9.4 +/**
9.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
9.6 + *
9.7 + * Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
9.8 + *
9.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
9.10 + * Other names may be trademarks of their respective owners.
9.11 + *
9.12 + * The contents of this file are subject to the terms of either the GNU
9.13 + * General Public License Version 2 only ("GPL") or the Common
9.14 + * Development and Distribution License("CDDL") (collectively, the
9.15 + * "License"). You may not use this file except in compliance with the
9.16 + * License. You can obtain a copy of the License at
9.17 + * http://www.netbeans.org/cddl-gplv2.html
9.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
9.19 + * specific language governing permissions and limitations under the
9.20 + * License. When distributing the software, include this License Header
9.21 + * Notice in each file and include the License file at
9.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
9.23 + * particular file as subject to the "Classpath" exception as provided
9.24 + * by Oracle in the GPL Version 2 section of the License file that
9.25 + * accompanied this code. If applicable, add the following below the
9.26 + * License Header, with the fields enclosed by brackets [] replaced by
9.27 + * your own identifying information:
9.28 + * "Portions Copyrighted [year] [name of copyright owner]"
9.29 + *
9.30 + * Contributor(s):
9.31 + *
9.32 + * The Original Software is NetBeans. The Initial Developer of the Original
9.33 + * Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
9.34 + *
9.35 + * If you wish your version of this file to be governed by only the CDDL
9.36 + * or only the GPL Version 2, indicate your decision by adding
9.37 + * "[Contributor] elects to include this software in this distribution
9.38 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
9.39 + * single choice of license, a recipient has the option to distribute
9.40 + * your version of this file under either the CDDL, the GPL Version 2 or
9.41 + * to extend the choice of license to its licensees as provided above.
9.42 + * However, if you add GPL Version 2 code and therefore, elected the GPL
9.43 + * Version 2 license, then the option applies only if the new code is
9.44 + * made subject to such option by the copyright holder.
9.45 + */
9.46 +package org.netbeans.html.boot.impl;
9.47 +
9.48 +/** Fake class to cause confusion in the generated code and force it
9.49 + * to use fully qualified names
9.50 + */
9.51 +final class Object {
9.52 +}