Some 1.5 cleanups.
Patch by: jat
Review by: me
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1445 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java b/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java
index 3652f2b..29a188e 100644
--- a/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java
@@ -59,9 +59,6 @@
*/
private class CompilerImpl extends Compiler {
- // TODO: is this used anywhere?
- public HashSet resolved = new HashSet();
-
private Set<CompilationUnitDeclaration> cuds;
public CompilerImpl(INameEnvironment environment,
diff --git a/dev/core/src/com/google/gwt/dev/jdt/ByteCodeCompiler.java b/dev/core/src/com/google/gwt/dev/jdt/ByteCodeCompiler.java
index 07dfb7d..6d144fe 100644
--- a/dev/core/src/com/google/gwt/dev/jdt/ByteCodeCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/jdt/ByteCodeCompiler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 Google Inc.
+ * Copyright 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -136,6 +136,7 @@
cacheManager.removeStaleByteCode(logger, this);
}
+ @Override
protected void doAcceptResult(CompilationResult result) {
// Take all compiled class files and put them in the byte cache.
//
@@ -166,6 +167,7 @@
* removes and pretends it didn't see any bytecode that is out-of-date with
* respect to the compilation unit that provides it.
*/
+ @Override
protected ByteCode doGetByteCodeFromCache(TreeLogger logger,
String binaryTypeName) {
return cacheManager.getByteCode(binaryTypeName);
diff --git a/dev/core/src/com/google/gwt/dev/jdt/CacheManager.java b/dev/core/src/com/google/gwt/dev/jdt/CacheManager.java
index e581a71..6c1afda 100644
--- a/dev/core/src/com/google/gwt/dev/jdt/CacheManager.java
+++ b/dev/core/src/com/google/gwt/dev/jdt/CacheManager.java
@@ -940,7 +940,7 @@
invalidateChangedFiles(logger, compiler);
}
- void setTypeForBinding(SourceTypeBinding binding, JClassType type) {
+ void setTypeForBinding(ReferenceBinding binding, JClassType type) {
identityMapper.put(binding, type);
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/BrowserWidget.java b/dev/core/src/com/google/gwt/dev/shell/BrowserWidget.java
index 6e13494..6678470 100644
--- a/dev/core/src/com/google/gwt/dev/shell/BrowserWidget.java
+++ b/dev/core/src/com/google/gwt/dev/shell/BrowserWidget.java
@@ -115,7 +115,7 @@
} else if (evt.widget == openWebModeButton) {
// first, compile
Set<String> keySet = new HashSet<String>();
- for (Map.Entry<?,ModuleSpace> entry : loadedModules.entrySet()) {
+ for (Map.Entry<?, ModuleSpace> entry : loadedModules.entrySet()) {
ModuleSpace module = entry.getValue();
keySet.add(module.getModuleName());
}
@@ -208,7 +208,7 @@
}
protected Browser browser;
-
+
private Color bgColor = new Color(null, 239, 237, 216);
private Button goButton;
@@ -237,7 +237,7 @@
Composite secondBar = buildLocationBar(this);
browser = new Browser(this, SWT.NONE);
-
+
{
statusBar = new Label(this, SWT.BORDER | SWT.SHADOW_IN);
statusBar.setBackground(bgColor);
@@ -317,7 +317,7 @@
logger.log(TreeLogger.SPAM, "Loading module " + space.getModuleName()
+ " (id " + key.toString() + ")", null);
-
+
// Let the space do its thing.
//
space.onLoad(logger);
@@ -328,34 +328,34 @@
}
/**
- * Unload one or more modules. If key is null, emulate old behavior
- * by unloading all loaded modules.
+ * Unload one or more modules. If key is null, emulate old behavior by
+ * unloading all loaded modules.
*
- * @param key unique key to identify module to unload or null for all
+ * @param key unique key to identify module to unload or null for all
*/
protected void doUnload(Object key) {
if (key == null) {
// BEGIN BACKWARD COMPATIBILITY
// remove all modules
- for (Map.Entry<?,ModuleSpace> entry : loadedModules.entrySet()) {
+ for (Map.Entry<?, ModuleSpace> entry : loadedModules.entrySet()) {
unloadModule(entry.getValue());
}
loadedModules.clear();
// END BACKWARD COMPATIBILITY
} else {
ModuleSpace moduleSpace = loadedModules.get(key);
- if (moduleSpace == null) {
- throw new HostedModeException("Can't find frame window for " + key);
+ if (moduleSpace != null) {
+ // If the module failed to load at all, it may not be in the map.
+ unloadModule(moduleSpace);
+ loadedModules.remove(key);
}
- unloadModule(moduleSpace);
- loadedModules.remove(key);
}
if (loadedModules.isEmpty()) {
if (!toolbar.openWebModeButton.isDisposed()) {
// Disable the compile button.
//
toolbar.openWebModeButton.setEnabled(false);
- }
+ }
}
}
@@ -368,8 +368,8 @@
String moduleName = moduleSpace.getModuleName();
Object key = moduleSpace.getKey();
moduleSpace.dispose();
- logger.log(TreeLogger.SPAM, "Unloading module " + moduleName
- + " (id " + key.toString() + ")", null);
+ logger.log(TreeLogger.SPAM, "Unloading module " + moduleName + " (id "
+ + key.toString() + ")", null);
}
private Composite buildLocationBar(Composite parent) {
diff --git a/dev/core/src/com/google/gwt/dev/shell/JsValue.java b/dev/core/src/com/google/gwt/dev/shell/JsValue.java
index eeeb394..6b2d9f4 100644
--- a/dev/core/src/com/google/gwt/dev/shell/JsValue.java
+++ b/dev/core/src/com/google/gwt/dev/shell/JsValue.java
@@ -260,11 +260,12 @@
* Set the JS object to the supplied object, which will be wrapped in a
* platform-dependent JavaScript class.
*
+ * @param <T> the type of the Java object to wrap
* @param cl the classloader to create the wrapper object with
* @param val the Java object to wrap
* @throws HostedModeException
*/
- public abstract void setWrappedJavaObject(CompilingClassLoader cl, Object val);
+ public abstract <T> void setWrappedJavaObject(CompilingClassLoader cl, T val);
/**
* Produce a string representation of the JsValue.
diff --git a/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java b/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
index b970e39..4382e31 100644
--- a/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
+++ b/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 Google Inc.
+ * Copyright 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -38,7 +38,8 @@
* @param type The subclass of JavaScriptObject to create
* @return the constructed JavaScriptObject
*/
- public static Object createJavaScriptObject(JsValue value, Class<?> type) {
+ public static <T> T createJavaScriptObject(JsValue value,
+ Class<? extends T> type) {
try {
// checkThread();
if (!value.isJavaScriptObject()) {
@@ -54,9 +55,9 @@
}
/* create the object using the default constructor */
- Constructor<?> ctor = type.getDeclaredConstructor(new Class[] {});
+ Constructor<? extends T> ctor = type.getDeclaredConstructor();
ctor.setAccessible(true);
- Object jso = ctor.newInstance(new Object[] {});
+ T jso = ctor.newInstance();
/* set the hostedModeReference field to this JsValue using reflection */
Field referenceField = jsoType.getDeclaredField("hostedModeReference");
@@ -91,7 +92,8 @@
* @throws HostedModeException if the JavaScript object is not assignable to
* the supplied type.
*/
- public static Object get(JsValue value, Class<?> type, String msgPrefix) {
+ public static <T> T get(JsValue value, Class<? extends T> type,
+ String msgPrefix) {
double doubleVal;
if (value.isNull()) {
return null;
@@ -102,7 +104,7 @@
+ ": JavaScript undefined, expected " + type.getName());
}
if (value.isWrappedJavaObject()) {
- Object origObject = value.getWrappedJavaObject();
+ T origObject = (T) value.getWrappedJavaObject();
if (!type.isAssignableFrom(origObject.getClass())) {
throw new HostedModeException(msgPrefix + ": Java object of type "
+ origObject.getClass().getName() + ", expected " + type.getName());
@@ -123,16 +125,16 @@
throw new HostedModeException(msgPrefix + ": JS value of type "
+ value.getTypeString() + ", expected boolean");
}
- return Boolean.valueOf(value.getBoolean());
+ return (T) Boolean.valueOf(value.getBoolean());
case TypeInfo.TYPE_WRAP_BYTE:
case TypeInfo.TYPE_PRIM_BYTE:
- return new Byte((byte) getIntRange(value, Byte.MIN_VALUE,
+ return (T) new Byte((byte) getIntRange(value, Byte.MIN_VALUE,
Byte.MAX_VALUE, "byte", msgPrefix));
case TypeInfo.TYPE_WRAP_CHAR:
case TypeInfo.TYPE_PRIM_CHAR:
- return new Character((char) getIntRange(value, Character.MIN_VALUE,
+ return (T) new Character((char) getIntRange(value, Character.MIN_VALUE,
Character.MAX_VALUE, "char", msgPrefix));
case TypeInfo.TYPE_WRAP_DOUBLE:
@@ -141,7 +143,7 @@
throw new HostedModeException(msgPrefix + ": JS value of type "
+ value.getTypeString() + ", expected double");
}
- return new Double(value.getNumber());
+ return (T) new Double(value.getNumber());
case TypeInfo.TYPE_WRAP_FLOAT:
case TypeInfo.TYPE_PRIM_FLOAT:
@@ -170,11 +172,11 @@
throw new HostedModeException(msgPrefix + ": JS value " + doubleVal
+ " out of range for a float");
}
- return new Float(floatVal);
+ return (T) new Float(floatVal);
case TypeInfo.TYPE_WRAP_INT:
case TypeInfo.TYPE_PRIM_INT:
- return new Integer(getIntRange(value, Integer.MIN_VALUE,
+ return (T) new Integer(getIntRange(value, Integer.MIN_VALUE,
Integer.MAX_VALUE, "int", msgPrefix));
case TypeInfo.TYPE_WRAP_LONG:
@@ -195,11 +197,11 @@
ModuleSpace.getLogger().log(TreeLogger.WARN,
msgPrefix + ": Loss of precision converting double to long", null);
}
- return new Long(longVal);
+ return (T) new Long(longVal);
case TypeInfo.TYPE_WRAP_SHORT:
case TypeInfo.TYPE_PRIM_SHORT:
- return new Short((short) getIntRange(value, Short.MIN_VALUE,
+ return (T) new Short((short) getIntRange(value, Short.MIN_VALUE,
Short.MAX_VALUE, "short", msgPrefix));
case TypeInfo.TYPE_WRAP_STRING:
@@ -207,11 +209,11 @@
throw new HostedModeException(msgPrefix + ": JS value of type "
+ value.getTypeString() + ", expected string");
}
- return value.getString();
+ return (T) value.getString();
case TypeInfo.TYPE_USER:
if (value.isString()) {
- return value.getString();
+ return (T) value.getString();
}
// if it isn't a String, it's an error, break to error
break;
@@ -265,8 +267,8 @@
* @param type static type of the object
* @param obj the object to store in the JS value
*/
- public static void set(JsValue value, CompilingClassLoader cl, Class<?> type,
- Object obj) {
+ public static <T> void set(JsValue value, CompilingClassLoader cl,
+ Class<?> type, T obj) {
if (obj == null) {
value.setNull();
} else if (type.equals(String.class)) {
diff --git a/dev/core/src/com/google/gwt/dev/shell/ModuleSpace.java b/dev/core/src/com/google/gwt/dev/shell/ModuleSpace.java
index 813cfb6..1ae06b3 100644
--- a/dev/core/src/com/google/gwt/dev/shell/ModuleSpace.java
+++ b/dev/core/src/com/google/gwt/dev/shell/ModuleSpace.java
@@ -182,7 +182,7 @@
public boolean invokeNativeBoolean(String name, Object jthis,
Class<?>[] types, Object[] args) throws Throwable {
JsValue result = invokeNative(name, jthis, types, args);
- Boolean value = (Boolean) JsValueGlue.get(result, Boolean.class,
+ Boolean value = JsValueGlue.get(result, Boolean.class,
"invokeNativeBoolean(" + name + ")");
return value.booleanValue();
}
@@ -190,7 +190,7 @@
public byte invokeNativeByte(String name, Object jthis, Class<?>[] types,
Object[] args) throws Throwable {
JsValue result = invokeNative(name, jthis, types, args);
- Byte value = (Byte) JsValueGlue.get(result, Byte.class, "invokeNativeByte("
+ Byte value = JsValueGlue.get(result, Byte.class, "invokeNativeByte("
+ name + ")");
return value.byteValue();
}
@@ -198,7 +198,7 @@
public char invokeNativeChar(String name, Object jthis, Class<?>[] types,
Object[] args) throws Throwable {
JsValue result = invokeNative(name, jthis, types, args);
- Character value = (Character) JsValueGlue.get(result, Character.class,
+ Character value = JsValueGlue.get(result, Character.class,
"invokeNativeCharacter(" + name + ")");
return value.charValue();
}
@@ -206,7 +206,7 @@
public double invokeNativeDouble(String name, Object jthis, Class<?>[] types,
Object[] args) throws Throwable {
JsValue result = invokeNative(name, jthis, types, args);
- Double value = (Double) JsValueGlue.get(result, Double.class,
+ Double value = JsValueGlue.get(result, Double.class,
"invokeNativeDouble(" + name + ")");
return value.doubleValue();
}
@@ -214,7 +214,7 @@
public float invokeNativeFloat(String name, Object jthis, Class<?>[] types,
Object[] args) throws Throwable {
JsValue result = invokeNative(name, jthis, types, args);
- Float value = (Float) JsValueGlue.get(result, Float.class,
+ Float value = JsValueGlue.get(result, Float.class,
"invokeNativeFloat(" + name + ")");
return value.floatValue();
}
@@ -230,7 +230,7 @@
public int invokeNativeInt(String name, Object jthis, Class<?>[] types,
Object[] args) throws Throwable {
JsValue result = invokeNative(name, jthis, types, args);
- Integer value = (Integer) JsValueGlue.get(result, Integer.class,
+ Integer value = JsValueGlue.get(result, Integer.class,
"invokeNativeInteger(" + name + ")");
return value.intValue();
}
@@ -238,7 +238,7 @@
public long invokeNativeLong(String name, Object jthis, Class<?>[] types,
Object[] args) throws Throwable {
JsValue result = invokeNative(name, jthis, types, args);
- Long value = (Long) JsValueGlue.get(result, Long.class, "invokeNativeLong("
+ Long value = JsValueGlue.get(result, Long.class, "invokeNativeLong("
+ name + ")");
return value.longValue();
}
@@ -253,7 +253,7 @@
public short invokeNativeShort(String name, Object jthis, Class<?>[] types,
Object[] args) throws Throwable {
JsValue result = invokeNative(name, jthis, types, args);
- Short value = (Short) JsValueGlue.get(result, Short.class,
+ Short value = JsValueGlue.get(result, Short.class,
"invokeNativeShort(" + name + ")");
return value.shortValue();
}
@@ -261,7 +261,7 @@
public String invokeNativeString(String name, Object jthis, Class<?>[] types,
Object[] args) throws Throwable {
JsValue result = invokeNative(name, jthis, types, args);
- return (String) JsValueGlue.get(result, String.class, "invokeNativeString("
+ return JsValueGlue.get(result, String.class, "invokeNativeString("
+ name + ")");
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/ShellModuleSpaceHost.java b/dev/core/src/com/google/gwt/dev/shell/ShellModuleSpaceHost.java
index 72e8028..275e82e 100644
--- a/dev/core/src/com/google/gwt/dev/shell/ShellModuleSpaceHost.java
+++ b/dev/core/src/com/google/gwt/dev/shell/ShellModuleSpaceHost.java
@@ -51,17 +51,21 @@
private RebindOracle rebindOracle;
+ private final boolean saveJsni;
+
private ModuleSpace space;
/**
* @param module the module associated with the hosted module space
+ * @param saveJsni
*/
public ShellModuleSpaceHost(TreeLogger logger, TypeOracle typeOracle,
- ModuleDef module, File genDir, File outDir) {
+ ModuleDef module, File genDir, File outDir, boolean saveJsni) {
this.logger = logger;
this.typeOracle = typeOracle;
this.module = module;
this.genDir = genDir;
+ this.saveJsni = saveJsni;
// Combine the user's output dir with the module name to get the
// module-specific output dir.
@@ -89,7 +93,8 @@
// Create a host for the hosted mode compiler.
// We add compilation units to it as deferred binding generators write them.
//
- SourceOracle srcOracle = new HostedModeSourceOracle(typeOracle);
+ SourceOracle srcOracle = new HostedModeSourceOracle(typeOracle, saveJsni
+ ? genDir : null);
// Create or find the compiler to be used by the compiling class loader.
//
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/CheckForUpdatesSaf.java b/dev/mac/src/com/google/gwt/dev/shell/mac/CheckForUpdatesSaf.java
index fa849b1..34ad6e2 100644
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/CheckForUpdatesSaf.java
+++ b/dev/mac/src/com/google/gwt/dev/shell/mac/CheckForUpdatesSaf.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 Google Inc.
+ * Copyright 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -22,6 +22,7 @@
*/
public class CheckForUpdatesSaf extends CheckForUpdates {
+ @Override
protected byte[] doHttpGet(String userAgent, String url) {
// Don't attempt to support proxies on Linux.
//
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/JsValueSaf.java b/dev/mac/src/com/google/gwt/dev/shell/mac/JsValueSaf.java
index 1d25655..afedef1 100644
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/JsValueSaf.java
+++ b/dev/mac/src/com/google/gwt/dev/shell/mac/JsValueSaf.java
@@ -85,11 +85,13 @@
init(jsval);
}
+ @Override
public boolean getBoolean() {
int curExecState = LowLevelSaf.getExecState();
return LowLevelSaf.coerceToBoolean(curExecState, jsval);
}
+ @Override
public int getInt() {
int curExecState = LowLevelSaf.getExecState();
return LowLevelSaf.coerceToInt(curExecState, jsval);
@@ -99,42 +101,51 @@
return jsval;
}
+ @Override
public double getNumber() {
int curExecState = LowLevelSaf.getExecState();
return LowLevelSaf.coerceToDouble(curExecState, jsval);
}
+ @Override
public String getString() {
int curExecState = LowLevelSaf.getExecState();
return LowLevelSaf.coerceToString(curExecState, jsval);
}
+ @Override
public String getTypeString() {
return LowLevelSaf.getTypeString(jsval);
}
+ @Override
public Object getWrappedJavaObject() {
DispatchObject obj = LowLevelSaf.unwrapDispatch(jsval);
return obj.getTarget();
}
+ @Override
public boolean isBoolean() {
return LowLevelSaf.isBoolean(jsval);
}
+ @Override
public boolean isInt() {
// Safari doesn't have integers, so this is always false
return false;
}
+ @Override
public boolean isJavaScriptObject() {
return LowLevelSaf.isObject(jsval) && !LowLevelSaf.isWrappedDispatch(jsval);
}
+ @Override
public boolean isNull() {
return LowLevelSaf.isNull(jsval);
}
+ @Override
public boolean isNumber() {
return LowLevelSaf.isNumber(jsval);
}
@@ -143,34 +154,42 @@
return LowLevelSaf.isObject(jsval);
}
+ @Override
public boolean isString() {
return LowLevelSaf.isString(jsval);
}
+ @Override
public boolean isUndefined() {
return LowLevelSaf.isUndefined(jsval);
}
+ @Override
public boolean isWrappedJavaObject() {
return LowLevelSaf.isWrappedDispatch(jsval);
}
+ @Override
public void setBoolean(boolean val) {
setJsVal(LowLevelSaf.convertBoolean(val));
}
+ @Override
public void setByte(byte val) {
setJsVal(LowLevelSaf.convertDouble(val));
}
+ @Override
public void setChar(char val) {
setJsVal(LowLevelSaf.convertDouble(val));
}
+ @Override
public void setDouble(double val) {
setJsVal(LowLevelSaf.convertDouble(val));
}
+ @Override
public void setInt(int val) {
setJsVal(LowLevelSaf.convertDouble(val));
}
@@ -186,22 +205,27 @@
init(jsval);
}
+ @Override
public void setNull() {
setJsVal(LowLevelSaf.jsNull());
}
+ @Override
public void setShort(short val) {
setJsVal(LowLevelSaf.convertDouble(val));
}
+ @Override
public void setString(String val) {
setJsVal(LowLevelSaf.convertString(val));
}
+ @Override
public void setUndefined() {
setJsVal(LowLevelSaf.jsUndefined());
}
+ @Override
public void setValue(JsValue other) {
int jsvalOther = ((JsValueSaf)other).jsval;
/*
@@ -212,7 +236,8 @@
setJsVal(jsvalOther);
}
- public void setWrappedJavaObject(CompilingClassLoader cl, Object val) {
+ @Override
+ public <T> void setWrappedJavaObject(CompilingClassLoader cl, T val) {
DispatchObject dispObj;
if (val == null) {
setNull();
@@ -225,6 +250,7 @@
setJsVal(LowLevelSaf.wrapDispatch(dispObj));
}
+ @Override
protected JsCleanup createCleanupObject() {
return new JsCleanupSaf(jsval, creationStackTrace);
}
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/LowLevelSaf.java b/dev/mac/src/com/google/gwt/dev/shell/mac/LowLevelSaf.java
index 03cc60d..7912d15 100644
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/LowLevelSaf.java
+++ b/dev/mac/src/com/google/gwt/dev/shell/mac/LowLevelSaf.java
@@ -64,7 +64,7 @@
private static boolean sInitialized = false;
- private static ThreadLocal stateStack = new ThreadLocal();
+ private static ThreadLocal<Stack<Integer>> stateStack = new ThreadLocal<Stack<Integer>>();
public static boolean coerceToBoolean(int execState, int jsval) {
boolean[] rval = new boolean[1];
@@ -230,11 +230,11 @@
}
public static int getExecState() {
- Stack stack = (Stack) stateStack.get();
+ Stack<Integer> stack = stateStack.get();
if (stack == null) {
throw new RuntimeException("No thread local execState stack!");
}
- Integer top = (Integer) stack.peek();
+ Integer top = stack.peek();
return top.intValue();
}
@@ -392,20 +392,20 @@
}
public static void popExecState(int execState) {
- Stack stack = (Stack) stateStack.get();
+ Stack<Integer> stack = stateStack.get();
if (stack == null) {
throw new RuntimeException("No thread local execState stack!");
}
- Integer old = (Integer) stack.pop();
+ Integer old = stack.pop();
if (old.intValue() != execState) {
throw new RuntimeException("The wrong execState was popped.");
}
}
public static void pushExecState(int execState) {
- Stack stack = (Stack) stateStack.get();
+ Stack<Integer> stack = stateStack.get();
if (stack == null) {
- stack = new Stack();
+ stack = new Stack<Integer>();
stateStack.set(stack);
}
stack.push(new Integer(execState));
@@ -503,8 +503,8 @@
private static native boolean _getGlobalExecState(int scriptObject, int[] rval);
- private static native boolean _initNative(Class dispObjClass,
- Class dispMethClass);
+ private static native boolean _initNative(Class<DispatchObject> dispObjClass,
+ Class<DispatchMethod> dispMethClass);
private static native boolean _invoke(int execState, int scriptObject,
String methodName, int jsthis, int jsargCount, int[] jsargs, int[] rval);
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/MethodDispatch.java b/dev/mac/src/com/google/gwt/dev/shell/mac/MethodDispatch.java
index 87cf270..a864d98 100644
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/MethodDispatch.java
+++ b/dev/mac/src/com/google/gwt/dev/shell/mac/MethodDispatch.java
@@ -18,6 +18,7 @@
import com.google.gwt.dev.shell.CompilingClassLoader;
import com.google.gwt.dev.shell.JsValue;
import com.google.gwt.dev.shell.JsValueGlue;
+import com.google.gwt.dev.shell.ModuleSpace;
import com.google.gwt.dev.shell.mac.LowLevelSaf.DispatchMethod;
import java.lang.reflect.InvocationTargetException;
@@ -34,11 +35,7 @@
private final Method method;
- // TODO(jat): remove these references
- // private final int scriptObject;
-
public MethodDispatch(CompilingClassLoader classLoader, Method method) {
- // this.scriptObject = scriptObject;
this.classLoader = classLoader;
this.method = method;
}
@@ -52,7 +49,7 @@
}
JsValueSaf returnValue = new JsValueSaf();
try {
- Class[] paramTypes = method.getParameterTypes();
+ Class<?>[] paramTypes = method.getParameterTypes();
int argc = paramTypes.length;
Object args[] = new Object[argc];
if (jsargs.length < argc) {
@@ -84,7 +81,7 @@
// If we get here, it means an exception is being thrown from
// Java back into JavaScript
Throwable t = e.getTargetException();
- ModuleSpaceSaf.setThrownJavaException(t);
+ ModuleSpace.setThrownJavaException(t);
LowLevelSaf.raiseJavaScriptException(execState, LowLevelSaf.jsNull());
return LowLevelSaf.jsUndefined();
}
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/ModuleSpaceSaf.java b/dev/mac/src/com/google/gwt/dev/shell/mac/ModuleSpaceSaf.java
index 70b4533..b6d371d 100644
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/ModuleSpaceSaf.java
+++ b/dev/mac/src/com/google/gwt/dev/shell/mac/ModuleSpaceSaf.java
@@ -54,6 +54,7 @@
newScript, file, line);
}
+ @Override
public void dispose() {
LowLevelSaf.gcUnlock(window, null);
super.dispose();
@@ -68,7 +69,8 @@
* @param args the arguments to be passed
* @return the return value as a Object.
*/
- protected JsValue doInvoke(String name, Object jthis, Class[] types,
+ @Override
+ protected JsValue doInvoke(String name, Object jthis, Class<?>[] types,
Object[] args) {
int jsthis = wrapObjectAsJSObject(jthis);
int curExecState = LowLevelSaf.getExecState();
@@ -84,6 +86,7 @@
return new JsValueSaf(result);
}
+ @Override
protected Object getStaticDispatcher() {
return new WebKitDispatchAdapter(getIsolatedClassLoader());
}
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/WebKitDispatchAdapter.java b/dev/mac/src/com/google/gwt/dev/shell/mac/WebKitDispatchAdapter.java
index 409c3bd..f8065b9 100644
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/WebKitDispatchAdapter.java
+++ b/dev/mac/src/com/google/gwt/dev/shell/mac/WebKitDispatchAdapter.java
@@ -113,6 +113,7 @@
javaDispatch.setFieldValue(dispId, val);
}
+ @Override
public String toString() {
return getTarget().toString();
}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/BrowserWidgetIE6.java b/dev/windows/src/com/google/gwt/dev/shell/ie/BrowserWidgetIE6.java
index aafacab..ee15d81 100644
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/BrowserWidgetIE6.java
+++ b/dev/windows/src/com/google/gwt/dev/shell/ie/BrowserWidgetIE6.java
@@ -80,6 +80,7 @@
}
}
+ @Override
protected void getIDsOfNames(String[] names, int[] ids)
throws HResultException {
@@ -109,6 +110,7 @@
doUnload(key);
}
+ @Override
protected Variant invoke(int dispId, int flags, Variant[] params)
throws HResultException, InvocationTargetException {
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/COMObjectProxy.java b/dev/windows/src/com/google/gwt/dev/shell/ie/COMObjectProxy.java
index 53bb5f2..e1e8ec2 100644
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/COMObjectProxy.java
+++ b/dev/windows/src/com/google/gwt/dev/shell/ie/COMObjectProxy.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 Google Inc.
+ * Copyright 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -70,13 +70,13 @@
this.target = victim;
// Get the COMObject ObjectMap so that we can hijack the target's slot.
- Map objectMap = (Map) LowLevel.snatchFieldObjectValue(COMObject.class,
+ Map<Integer, COMObject> objectMap = (Map<Integer, COMObject>) LowLevel.snatchFieldObjectValue(COMObject.class,
null, "ObjectMap");
Integer ppVtableTarget = new Integer(target.getAddress());
// First, make sure that the target is still actually in the map.
// If it isn't still in there, then the caller is using me incorrectly.
- Object currValue = objectMap.get(ppVtableTarget);
+ COMObject currValue = objectMap.get(ppVtableTarget);
if (currValue != target) {
throw new IllegalStateException("target object is not currently mapped");
}
@@ -88,67 +88,83 @@
objectMap.put(ppVtableTarget, this);
}
+ @Override
public int method0(int[] args) {
return target.method0(args);
}
+ @Override
public int method1(int[] args) {
return target.method1(args);
}
+ @Override
public int method10(int[] args) {
return target.method10(args);
}
+ @Override
public int method11(int[] args) {
return target.method11(args);
}
+ @Override
public int method12(int[] args) {
return target.method12(args);
}
+ @Override
public int method13(int[] args) {
return target.method13(args);
}
+ @Override
public int method14(int[] args) {
return target.method14(args);
}
+ @Override
public int method15(int[] args) {
return target.method15(args);
}
+ @Override
public int method16(int[] args) {
return target.method16(args);
}
+ @Override
public int method17(int[] args) {
return target.method17(args);
}
+ @Override
public int method18(int[] args) {
return target.method18(args);
}
+ @Override
public int method19(int[] args) {
return target.method19(args);
}
+ @Override
public int method2(int[] args) {
return target.method2(args);
}
+ @Override
public int method20(int[] args) {
return target.method20(args);
}
+ @Override
public int method21(int[] args) {
return target.method21(args);
}
+ @Override
public int method22(int[] args) {
return target.method22(args);
}
-}
\ No newline at end of file
+}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/CheckForUpdatesIE6.java b/dev/windows/src/com/google/gwt/dev/shell/ie/CheckForUpdatesIE6.java
index 0754849..fd71509 100644
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/CheckForUpdatesIE6.java
+++ b/dev/windows/src/com/google/gwt/dev/shell/ie/CheckForUpdatesIE6.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 Google Inc.
+ * Copyright 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -26,6 +26,7 @@
LowLevelIE6.init();
}
+ @Override
protected byte[] doHttpGet(String userAgent, String url) {
byte[] response = LowLevelIE6.httpGet(userAgent, url);
return response;
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchImpl.java b/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchImpl.java
index b66e86e..2068695 100644
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchImpl.java
+++ b/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 Google Inc.
+ * Copyright 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -152,7 +152,7 @@
// Convert it to a variant (if the return type is void, return
// a VT_EMPTY variant -- 'undefined' in JavaScript).
//
- Class returnType = method.getReturnType();
+ Class<?> returnType = method.getReturnType();
if (returnType.equals(Void.TYPE)) {
return new Variant();
}
@@ -172,10 +172,12 @@
// CHECKSTYLE_ON
+ @Override
public int method0(int[] args) {
return QueryInterface(args[0], args[1]);
}
+ @Override
public int method1(int[] args) {
return AddRef();
}
@@ -184,14 +186,17 @@
// method4 GetTypeInfo - not implemented
+ @Override
public int method2(int[] args) {
return Release();
}
+ @Override
public int method5(int[] args) {
return GetIDsOfNames(args[0], args[1], args[2], args[3], args[4]);
}
+ @Override
public int method6(int[] args) {
return Invoke(args[0], args[1], args[2], args[3], args[4], args[5],
args[6], args[7]);
@@ -206,18 +211,18 @@
COM.MoveMemory(guid, riid, GUID.sizeof);
if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
- COM.MoveMemory(ppvObject, new int[] {getAddress()}, 4);
+ OS.MoveMemory(ppvObject, new int[] {getAddress()}, 4);
AddRef();
return COM.S_OK;
}
if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) {
- COM.MoveMemory(ppvObject, new int[] {getAddress()}, 4);
+ OS.MoveMemory(ppvObject, new int[] {getAddress()}, 4);
AddRef();
return COM.S_OK;
}
- COM.MoveMemory(ppvObject, new int[] {0}, 4);
+ OS.MoveMemory(ppvObject, new int[] {0}, 4);
return COM.E_NOINTERFACE;
}
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchProxy.java b/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchProxy.java
index 916609f..00a4e2f 100644
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchProxy.java
+++ b/dev/windows/src/com/google/gwt/dev/shell/ie/IDispatchProxy.java
@@ -51,7 +51,7 @@
* </p>
* <ul>
* <li>Only late-bound dispatch is supported</li>
- * <li>Named arguments are not supported (see {@link #GetIDsOfNames)).</li>
+ * <li>Named arguments are not supported (see {@link #GetIDsOfNames})).</li>
* </ul>
*/
class IDispatchProxy extends IDispatchImpl {
@@ -95,6 +95,7 @@
* Must be called when the object is no longer needed (to release the global
* reference on the target object).
*/
+ @Override
public void dispose() {
// Release the global ref on myself.
if (myGlobalRef != 0) {
@@ -116,6 +117,7 @@
return isDisposed;
}
+ @Override
protected void getIDsOfNames(String[] names, int[] ids)
throws HResultException {
ids[0] = classLoader.getDispId(names[0]);
@@ -124,6 +126,7 @@
}
}
+ @Override
protected Variant invoke(int dispId, int flags, Variant[] params)
throws HResultException, InvocationTargetException {
try {
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/JsValueIE6.java b/dev/windows/src/com/google/gwt/dev/shell/ie/JsValueIE6.java
index f287bf5..d25c131 100644
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/JsValueIE6.java
+++ b/dev/windows/src/com/google/gwt/dev/shell/ie/JsValueIE6.java
@@ -89,6 +89,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#getBoolean()
*/
+ @Override
public boolean getBoolean() {
return variant.getBoolean();
}
@@ -98,6 +99,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#getInt()
*/
+ @Override
public int getInt() {
return variant.getInt();
}
@@ -107,6 +109,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#getNumber()
*/
+ @Override
public double getNumber() {
return variant.getDouble();
}
@@ -116,6 +119,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#getString()
*/
+ @Override
public String getString() {
return variant.getString();
}
@@ -125,6 +129,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#getTypeString()
*/
+ @Override
public String getTypeString() {
switch (variant.getType()) {
case COM.VT_BOOL:
@@ -164,6 +169,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#getWrappedJavaObject()
*/
+ @Override
public Object getWrappedJavaObject() {
return tryToUnwrapWrappedJavaObject();
}
@@ -173,6 +179,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#isBoolean()
*/
+ @Override
public boolean isBoolean() {
return variant != null && variant.getType() == COM.VT_BOOL;
}
@@ -182,6 +189,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#isInt()
*/
+ @Override
public boolean isInt() {
if (variant == null) {
return false;
@@ -204,6 +212,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#isJavaScriptObject()
*/
+ @Override
public boolean isJavaScriptObject() {
if (variant == null) {
return false;
@@ -219,6 +228,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#isNull()
*/
+ @Override
public boolean isNull() {
return variant != null && variant.getType() == COM.VT_NULL;
}
@@ -228,6 +238,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#isNumber()
*/
+ @Override
public boolean isNumber() {
if (variant == null) {
return false;
@@ -253,6 +264,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#isString()
*/
+ @Override
public boolean isString() {
if (variant == null) {
return false;
@@ -294,6 +306,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#isUndefined()
*/
+ @Override
public boolean isUndefined() {
return variant == null || variant.getType() == COM.VT_EMPTY;
}
@@ -303,6 +316,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#isWrappedJavaObject()
*/
+ @Override
public boolean isWrappedJavaObject() {
if (variant == null) {
return false;
@@ -318,6 +332,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#setBoolean(boolean)
*/
+ @Override
public void setBoolean(boolean val) {
setVariant(new Variant(val));
}
@@ -327,6 +342,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#setByte(byte)
*/
+ @Override
public void setByte(byte val) {
setVariant(new Variant(val));
}
@@ -336,6 +352,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#setChar(char)
*/
+ @Override
public void setChar(char val) {
setVariant(new Variant(val));
}
@@ -345,6 +362,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#setDouble(double)
*/
+ @Override
public void setDouble(double val) {
setVariant(new Variant(val));
}
@@ -354,6 +372,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#setInt(int)
*/
+ @Override
public void setInt(int val) {
setVariant(new Variant(val));
}
@@ -363,6 +382,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#setNull()
*/
+ @Override
public void setNull() {
setVariant(new Variant(0, COM.VT_NULL));
}
@@ -372,6 +392,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#setShort(short)
*/
+ @Override
public void setShort(short val) {
setVariant(new Variant(val));
}
@@ -381,6 +402,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#setString(java.lang.String)
*/
+ @Override
public void setString(String val) {
setVariant(new Variant(val));
}
@@ -390,10 +412,12 @@
*
* @see com.google.gwt.dev.shell.JsValue#setUndefined()
*/
+ @Override
public void setUndefined() {
setVariant(null);
}
+ @Override
public void setValue(JsValue other) {
setVariant(maybeCopyVariant(((JsValueIE6) other).variant));
}
@@ -404,7 +428,8 @@
* @see com.google.gwt.dev.shell.JsValue#setWrappedJavaObject(com.google.gwt.dev.shell.CompilingClassLoader,
* java.lang.Object)
*/
- public void setWrappedJavaObject(CompilingClassLoader cl, Object val) {
+ @Override
+ public <T> void setWrappedJavaObject(CompilingClassLoader cl, T val) {
IDispatchImpl dispObj;
if (val == null) {
setNull();
@@ -424,6 +449,7 @@
*
* @see com.google.gwt.dev.shell.JsValue#createCleanupObject()
*/
+ @Override
protected JsCleanup createCleanupObject() {
return new JsCleanupIE6(variant);
}
@@ -440,7 +466,7 @@
variant = val;
}
- private Object tryToUnwrapWrappedJavaObject() {
+ private <T> T tryToUnwrapWrappedJavaObject() {
/*
* This implementation copied from OleAutomation.invoke(). We used to have a
* varArg.getAutomation().invoke() implementation, but it turns out the
@@ -467,7 +493,7 @@
if (globalRef != 0) {
// This is really a Java object being passed back via an IDispatchProxy.
IDispatchProxy proxy = (IDispatchProxy) LowLevel.objFromGlobalRefInt(globalRef);
- return proxy.getTarget();
+ return (T) proxy.getTarget();
}
return null;
} finally {
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/MethodDispatch.java b/dev/windows/src/com/google/gwt/dev/shell/ie/MethodDispatch.java
index 9b47ce4..a192535 100644
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/MethodDispatch.java
+++ b/dev/windows/src/com/google/gwt/dev/shell/ie/MethodDispatch.java
@@ -42,7 +42,7 @@
* </p>
* <ul>
* <li>Only late-bound dispatch is supported</li>
- * <li>Named arguments are not supported (see {@link #GetIDsOfNames)).</li>
+ * <li>Named arguments are not supported (see {@link #GetIDsOfNames})).</li>
* </ul>
*/
class MethodDispatch extends IDispatchImpl {
@@ -56,6 +56,7 @@
this.method = method;
}
+ @Override
public String toString() {
return "\nfunction " + method.toString() + "(){\n [native code]\n}\n";
}
@@ -65,6 +66,7 @@
* flags. So we start with ID 1 for toString. {@link IDispatchProxy} and
* {@link BrowserWidgetIE6.External} should be fixed to do the same.
*/
+ @Override
protected void getIDsOfNames(String[] names, int[] ids)
throws HResultException {
if (names[0].equalsIgnoreCase("toString")) {
@@ -72,13 +74,14 @@
} else if (names[0].equalsIgnoreCase("call")) {
ids[0] = 2;
} else {
- throw new HResultException(IDispatchProxy.DISP_E_UNKNOWNNAME);
+ throw new HResultException(IDispatchImpl.DISP_E_UNKNOWNNAME);
}
}
/*
* Handles all the things the browser can do to a function object.
*/
+ @Override
protected Variant invoke(int id, int flags, Variant[] params)
throws HResultException, InvocationTargetException {
switch (id) {
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/ModuleSpaceIE6.java b/dev/windows/src/com/google/gwt/dev/shell/ie/ModuleSpaceIE6.java
index 681d4f3..77085c3 100644
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/ModuleSpaceIE6.java
+++ b/dev/windows/src/com/google/gwt/dev/shell/ie/ModuleSpaceIE6.java
@@ -113,6 +113,7 @@
}
}
+ @Override
public void dispose() {
// Dispose everything else.
if (window != null) {
@@ -130,7 +131,8 @@
* @param args the arguments to be passed
* @return the return value as a Variant.
*/
- protected JsValue doInvoke(String name, Object jthis, Class[] types,
+ @Override
+ protected JsValue doInvoke(String name, Object jthis, Class<?>[] types,
Object[] args) throws Throwable {
Variant[] vArgs = null;
try {
@@ -166,10 +168,12 @@
}
}
+ @Override
protected Object getStaticDispatcher() {
return new IDispatchProxy(getIsolatedClassLoader());
}
+ @Override
protected boolean isExceptionSame(Throwable original, int number, String name, String message) {
HResultException hre = new HResultException(original);
return CODE(hre.getHResult()) == CODE(number) && hre.getMessage().equals(message);
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/SwtOleGlue.java b/dev/windows/src/com/google/gwt/dev/shell/ie/SwtOleGlue.java
index 1ed7552..432f8cd 100644
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/SwtOleGlue.java
+++ b/dev/windows/src/com/google/gwt/dev/shell/ie/SwtOleGlue.java
@@ -37,7 +37,7 @@
* here so that Handles can be manipulated properly.
*/
public static Variant convertObjectToVariant(CompilingClassLoader cl,
- Class type, Object o) {
+ Class<?> type, Object o) {
if (type.equals(Variant.class)) {
return (Variant) o;
}
@@ -49,7 +49,7 @@
/**
* Converts an array of variants to their equivalent java objects.
*/
- public static Object[] convertVariantsToObjects(Class[] argTypes,
+ public static Object[] convertVariantsToObjects(Class<?>[] argTypes,
Variant[] varArgs, String msgPrefix) {
Object[] javaArgs = new Object[Math.min(varArgs.length, argTypes.length)];
for (int i = 0; i < javaArgs.length; i++) {
@@ -91,7 +91,7 @@
size = 8192;
}
char[] buffer = new char[(size + 1) / 2];
- COM.MoveMemory(buffer, pOleChar, size);
+ OS.MoveMemory(buffer, pOleChar, size);
String s = new String(buffer);
if (s.indexOf('\0') != -1) {
@@ -123,12 +123,14 @@
external.AddRef();
}
+ @Override
public int method15(int[] args) {
// GetExternal() is method 15.
//
return GetExternal(args[0]);
}
+ @Override
public int method2(int[] args) {
int result = super.method2(args);
if (result == 0) {