ordercheck passes.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@43 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/shell/BrowserDialog.java b/dev/core/src/com/google/gwt/dev/shell/BrowserDialog.java
index f0f886f..d91b146 100644
--- a/dev/core/src/com/google/gwt/dev/shell/BrowserDialog.java
+++ b/dev/core/src/com/google/gwt/dev/shell/BrowserDialog.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
@@ -20,6 +34,12 @@
*/
public class BrowserDialog extends DialogBase {
+ private final String html;
+
+ private final URL url;
+
+ private final TreeLogger logger;
+
public BrowserDialog(Shell parent, TreeLogger logger, String html) {
super(parent, 550, 520, true, false);
this.logger = logger;
@@ -32,19 +52,20 @@
browser.addTitleListener(new TitleListener() {
public void changed(TitleEvent event) {
- BrowserDialog.this.
- setText(event.title);
- }});
+ BrowserDialog.this.setText(event.title);
+ }
+ });
if (html != null) {
browser.setText(html);
} else if (url != null) {
browser.setUrl(url.toString());
}
-
+
browser.addLocationListener(new LocationListener() {
public void changed(LocationEvent event) {
}
+
public void changing(LocationEvent event) {
event.doit = false;
BrowserWidget.launchExternalBrowser(logger, event.location);
@@ -53,8 +74,4 @@
return browser;
}
-
- private final String html;
- private final URL url;
- private final TreeLogger logger;
}
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 f5d75ce..5224c1f 100644
--- a/dev/core/src/com/google/gwt/dev/shell/BrowserWidget.java
+++ b/dev/core/src/com/google/gwt/dev/shell/BrowserWidget.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
@@ -50,28 +64,34 @@
public abstract class BrowserWidget extends Composite {
private class Toolbar extends HeaderBarBase implements SelectionListener {
+ private final ToolItem backButton;
+
+ private final ToolItem forwardButton;
+
+ private final ToolItem openWebModeButton;
+
+ private final ToolItem refreshButton;
+ private final ToolItem stopButton;
+
public Toolbar(Composite parent) {
super(parent);
backButton = newItem("back.gif", " &Back ", "Go back one state");
backButton.addSelectionListener(this);
- forwardButton = newItem("forward.gif", "&Forward",
- "Go forward one state");
+ forwardButton = newItem("forward.gif", "&Forward", "Go forward one state");
forwardButton.addSelectionListener(this);
refreshButton = newItem("refresh.gif", " &Refresh ", "Reload the page");
refreshButton.addSelectionListener(this);
- stopButton = newItem("stop.gif", " &Stop ",
- "Stop loading the page");
+ stopButton = newItem("stop.gif", " &Stop ", "Stop loading the page");
stopButton.addSelectionListener(this);
newSeparator();
- openWebModeButton = newItem("new-web-mode-window.gif",
- "&Compile/Browse",
- "Compiles and opens the current URL in the system browser");
+ openWebModeButton = newItem("new-web-mode-window.gif", "&Compile/Browse",
+ "Compiles and opens the current URL in the system browser");
openWebModeButton.addSelectionListener(this);
openWebModeButton.setEnabled(false);
}
@@ -110,7 +130,7 @@
// Already logged by callee.
//
MessageBox msgBox = new MessageBox(getShell(), SWT.OK
- | SWT.ICON_ERROR);
+ | SWT.ICON_ERROR);
msgBox.setText("Compilation Failed");
msgBox.setMessage("Compilation failed. Please see the log in the development shell for details.");
msgBox.open();
@@ -127,15 +147,6 @@
launchExternalBrowser(logger, locationText);
}
}
-
- private final ToolItem backButton;
- private final ToolItem forwardButton;
-
- private final ToolItem openWebModeButton;
-
- private final ToolItem refreshButton;
-
- private final ToolItem stopButton;
}
static void launchExternalBrowser(TreeLogger logger, String location) {
@@ -150,8 +161,8 @@
return;
} catch (IOException e) {
logger.log(TreeLogger.ERROR,
- "Error launching GWT_EXTERNAL_BROWSER executable '" + browserCmd
- + "'", e);
+ "Error launching GWT_EXTERNAL_BROWSER executable '" + browserCmd
+ + "'", e);
return;
}
}
@@ -164,10 +175,9 @@
Runtime.getRuntime().exec(browserCmd);
return;
} catch (IOException e) {
- logger.log(
- TreeLogger.ERROR,
- "Error launching gwt.browser.default executable '" + browserCmd + "'",
- e);
+ logger.log(TreeLogger.ERROR,
+ "Error launching gwt.browser.default executable '" + browserCmd
+ + "'", e);
return;
}
}
@@ -179,21 +189,39 @@
return;
} else {
logger.log(TreeLogger.ERROR, "Error launching external HTML program '"
- + browserProgram.getName() + "'", null);
+ + browserProgram.getName() + "'", null);
return;
}
}
// We're out of options, so fail.
logger.log(TreeLogger.ERROR,
- "Unable to find a default external web browser", null);
+ "Unable to find a default external web browser", null);
logger.log(
- TreeLogger.WARN,
- "Try setting the environment varable GWT_EXTERNAL_BROWSER to your web browser executable before launching the GWT shell",
- null);
+ TreeLogger.WARN,
+ "Try setting the environment varable GWT_EXTERNAL_BROWSER to your web browser executable before launching the GWT shell",
+ null);
}
+ protected Browser browser;
+
+ private Color bgColor = new Color(null, 239, 237, 216);
+
+ private Button goButton;
+
+ private final BrowserWidgetHost host;
+
+ private Text location;
+
+ private final TreeLogger logger;
+
+ private Label statusBar;
+
+ private Toolbar toolbar;
+
+ private Map moduleSpacesByName = new HashMap();
+
public BrowserWidget(Composite parent, BrowserWidgetHost host) {
super(parent, SWT.NONE);
@@ -306,7 +334,7 @@
space.dispose();
logger.log(TreeLogger.SPAM, "Cleaning up resources for module "
- + moduleName, null);
+ + moduleName, null);
}
moduleSpacesByName.clear();
@@ -429,13 +457,13 @@
// no opinion either way
if (whitelistRuleFound == null && blacklistRuleFound == null) {
if (DialogBase.confirmAction(
- (Shell) getParent(),
- "Browsing to remote sites is a security risk! A malicious site could\r\n"
- + "execute Java code though this browser window. Only click \"Yes\" if you\r\n"
- + "are sure you trust the remote site. See the log for details and\r\n"
- + "configuration instructions.\r\n" + "\r\n" + "\r\n"
- + "Allow access to '" + url
- + "' for the rest of this session?\r\n", "Security Warning")) {
+ (Shell) getParent(),
+ "Browsing to remote sites is a security risk! A malicious site could\r\n"
+ + "execute Java code though this browser window. Only click \"Yes\" if you\r\n"
+ + "are sure you trust the remote site. See the log for details and\r\n"
+ + "configuration instructions.\r\n" + "\r\n" + "\r\n"
+ + "Allow access to '" + url
+ + "' for the rest of this session?\r\n", "Security Warning")) {
evt.doit = true;
BrowserWidgetHostChecker.whitelistURL(url);
} else {
@@ -470,13 +498,13 @@
break;
} else {
String msg = "Cannot find file '" + file.getAbsolutePath()
- + "'";
+ + "'";
TreeLogger branch = logger.branch(TreeLogger.ERROR, msg, null);
if ("gwt-hosted.html".equalsIgnoreCase(file.getName())) {
branch.log(
- TreeLogger.ERROR,
- "If you want to open compiled output within this hosted browser, add '?gwt.hybrid' to the end of the URL",
- null);
+ TreeLogger.ERROR,
+ "If you want to open compiled output within this hosted browser, add '?gwt.hybrid' to the end of the URL",
+ null);
}
}
file = file.getParentFile();
@@ -494,19 +522,18 @@
TreeLogger.Type msgType = TreeLogger.ERROR;
if (!evt.doit) {
header = logger.branch(msgType, "Unable to visit " + typeStr
- + " URL: '" + url, null);
+ + " URL: '" + url, null);
} else {
msgType = TreeLogger.WARN;
- header = logger.branch(
- TreeLogger.WARN,
- "Confirmation was required to visit " + typeStr + " URL: '" + url,
- null);
+ header = logger.branch(TreeLogger.WARN,
+ "Confirmation was required to visit " + typeStr + " URL: '"
+ + url, null);
}
if (blacklistRuleFound == null) {
BrowserWidgetHostChecker.notifyUntrustedHost(url, header, msgType);
} else {
BrowserWidgetHostChecker.notifyBlacklistedHost(blacklistRuleFound,
- url, header, msgType);
+ url, header, msgType);
}
setLocationText(browser.getUrl());
}
@@ -533,14 +560,4 @@
int length = text.length();
location.setSelection(length, length);
}
-
- protected Browser browser;
- private Color bgColor = new Color(null, 239, 237, 216);
- private Button goButton;
- private final BrowserWidgetHost host;
- private Text location;
- private final TreeLogger logger;
- private Label statusBar;
- private Toolbar toolbar;
- private Map moduleSpacesByName = new HashMap();
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java b/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java
index 4358bea..45e9984 100644
--- a/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java
+++ b/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHost.java
@@ -1,22 +1,37 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
/**
- * Interface that unifies access to the <code>BrowserWidget</code>, <code>ModuleSpaceHost</code>, and the compiler.
+ * Interface that unifies access to the <code>BrowserWidget</code>,
+ * <code>ModuleSpaceHost</code>, and the compiler.
*/
public interface BrowserWidgetHost {
- TreeLogger getLogger();
-
- BrowserWidget openNewBrowserWindow() throws UnableToCompleteException;
-
- String normalizeURL(String whatTheUserTyped);
+ void compile(String[] modules) throws UnableToCompleteException;
// Factor this out if BrowserWidget becomes decoupled from hosted mode
ModuleSpaceHost createModuleSpaceHost(BrowserWidget widget, String moduleName)
throws UnableToCompleteException;
- void compile(String[] modules) throws UnableToCompleteException;
+ TreeLogger getLogger();
+
+ String normalizeURL(String whatTheUserTyped);
+
+ BrowserWidget openNewBrowserWindow() throws UnableToCompleteException;
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHostChecker.java b/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHostChecker.java
index 11277a0..eedd9c5 100644
--- a/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHostChecker.java
+++ b/dev/core/src/com/google/gwt/dev/shell/BrowserWidgetHostChecker.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
@@ -33,6 +47,22 @@
*/
private static final Set validHttpHosts = new HashSet();
+ static {
+ alwaysValidHttpHosts.add("^https?://localhost");
+ alwaysValidHttpHosts.add("^file:");
+ alwaysValidHttpHosts.add("^about:");
+ alwaysValidHttpHosts.add("^res:");
+ alwaysValidHttpHosts.add("^javascript:");
+ alwaysValidHttpHosts.add("^([a-zA-Z][:])[/\\\\]");
+ // matches c:\ and c:/
+ alwaysValidHttpHosts.add("^https?://localhost/");
+ alwaysValidHttpHosts.add("^https?://localhost[.]localdomain/");
+ alwaysValidHttpHosts.add("^https?://127[.]0[.]0[.]1/");
+ alwaysValidHttpHosts.add("^https?://localhost$");
+ alwaysValidHttpHosts.add("^https?://localhost[.]localdomain$");
+ alwaysValidHttpHosts.add("^https?://127[.]0[.]0[.]1$");
+ }
+
/**
* This method blacklists the supplied regexes, separated by comma or space.
*
@@ -84,29 +114,6 @@
return "^" + escapeString(raw);
}
- private static String escapeString(String raw) {
- StringBuffer out = new StringBuffer();
- for (int i = 0; i < raw.length(); i++) {
- char c = raw.charAt(i);
- if (Character.isLetterOrDigit(c) || c == '-' || c == '_') {
- out.append(c);
- } else if (c == '\\') {
- out.append("[\\\\]");
- } else if (c == ']') {
- out.append("[\\]]");
- } else if (c == '^') {
- out.append("[\\^]");
- } else if (c == '[') {
- out.append("[\\[]");
- } else {
- out.append("[");
- out.append(c);
- out.append("]");
- }
- }
- return out.toString();
- }
-
/**
* This method formats the blacklist for display in the treeLogger.
*
@@ -188,9 +195,9 @@
public static void notifyBlacklistedHost(String blacklistRuleFound,
String url, TreeLogger header, TreeLogger.Type msgType) {
TreeLogger reason = header.branch(msgType, "reason: " + url
- + " is blacklisted", null);
+ + " is blacklisted", null);
reason.log(msgType, "To fix: remove \"" + blacklistRuleFound
- + "\" from system property gwt.hosts.blacklist", null);
+ + "\" from system property gwt.hosts.blacklist", null);
}
/**
@@ -207,18 +214,18 @@
String blackListStr = oldBlackList;
String hostRegex = computeHostRegex(url);
TreeLogger reason = header.branch(msgType, "reason: " + url
- + " is not in the whitelist", null);
+ + " is not in the whitelist", null);
reason.log(msgType, "whitelist: " + whiteListStr, null);
reason.log(msgType, "blacklist: " + blackListStr, null);
TreeLogger fix = header.branch(msgType, "To fix: add regex matching "
- + "URL to -whitelist command line argument", null);
+ + "URL to -whitelist command line argument", null);
fix.log(msgType, "Example: -whitelist=\"" + whiteListStr + " " + hostRegex
- + "\"", null);
+ + "\"", null);
TreeLogger reject = header.branch(msgType,
- "To reject automatically: add regex matching "
- + "URL to -blacklist command line argument", null);
+ "To reject automatically: add regex matching "
+ + "URL to -blacklist command line argument", null);
reject.log(msgType, "Example: -blacklist=\"" + blackListStr + " "
- + hostRegex + "\"", null);
+ + hostRegex + "\"", null);
}
/**
@@ -271,20 +278,27 @@
return true;
}
- static {
- alwaysValidHttpHosts.add("^https?://localhost");
- alwaysValidHttpHosts.add("^file:");
- alwaysValidHttpHosts.add("^about:");
- alwaysValidHttpHosts.add("^res:");
- alwaysValidHttpHosts.add("^javascript:");
- alwaysValidHttpHosts.add("^([a-zA-Z][:])[/\\\\]");
- // matches c:\ and c:/
- alwaysValidHttpHosts.add("^https?://localhost/");
- alwaysValidHttpHosts.add("^https?://localhost[.]localdomain/");
- alwaysValidHttpHosts.add("^https?://127[.]0[.]0[.]1/");
- alwaysValidHttpHosts.add("^https?://localhost$");
- alwaysValidHttpHosts.add("^https?://localhost[.]localdomain$");
- alwaysValidHttpHosts.add("^https?://127[.]0[.]0[.]1$");
+ private static String escapeString(String raw) {
+ StringBuffer out = new StringBuffer();
+ for (int i = 0; i < raw.length(); i++) {
+ char c = raw.charAt(i);
+ if (Character.isLetterOrDigit(c) || c == '-' || c == '_') {
+ out.append(c);
+ } else if (c == '\\') {
+ out.append("[\\\\]");
+ } else if (c == ']') {
+ out.append("[\\]]");
+ } else if (c == '^') {
+ out.append("[\\^]");
+ } else if (c == '[') {
+ out.append("[\\[]");
+ } else {
+ out.append("[");
+ out.append(c);
+ out.append("]");
+ }
+ }
+ return out.toString();
}
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/CheckForUpdates.java b/dev/core/src/com/google/gwt/dev/shell/CheckForUpdates.java
index 01dab92..f3022ef 100644
--- a/dev/core/src/com/google/gwt/dev/shell/CheckForUpdates.java
+++ b/dev/core/src/com/google/gwt/dev/shell/CheckForUpdates.java
@@ -75,6 +75,22 @@
private static final int VERSION_PARTS = 3;
private static final String VERSION_REGEXP = "\\d+\\.\\d+\\.\\d+";
+ static {
+ // Do this in a static initializer so we can ignore all exceptions.
+ //
+ boolean debugVersionCheck = false;
+ try {
+ if (System.getProperty("gwt.debugVersionCheck") != null) {
+ debugVersionCheck = true;
+ }
+ } catch (Throwable e) {
+ // Always silently ignore any errors.
+ //
+ } finally {
+ DEBUG_VERSION_CHECK = debugVersionCheck;
+ }
+ }
+
/**
* Determines whether the server version is definitively newer than the client
* version. If any errors occur in the comparison, this method returns false
@@ -89,13 +105,13 @@
if (clientVersion == null || serverVersion == null) {
return false;
}
-
+
// must match expected format
if (!clientVersion.matches(VERSION_REGEXP)
|| !serverVersion.matches(VERSION_REGEXP)) {
return false;
}
-
+
// extract the relevant parts
String[] clientParts = clientVersion.split("\\.");
String[] serverParts = serverVersion.split("\\.");
@@ -112,7 +128,7 @@
if (serverPart < clientPart) {
return false;
}
-
+
if (serverPart > clientPart) {
return true;
}
@@ -477,20 +493,4 @@
return ua;
}
-
- static {
- // Do this in a static initializer so we can ignore all exceptions.
- //
- boolean debugVersionCheck = false;
- try {
- if (System.getProperty("gwt.debugVersionCheck") != null) {
- debugVersionCheck = true;
- }
- } catch (Throwable e) {
- // Always silently ignore any errors.
- //
- } finally {
- DEBUG_VERSION_CHECK = debugVersionCheck;
- }
- }
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java b/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
index 02f92e1..454b759 100644
--- a/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
+++ b/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
@@ -17,10 +31,10 @@
/**
*
- * TODO : we should refactor this class to move the getClassInfoByDispId,
+ * TODO : we should refactor this class to move the getClassInfoByDispId,
* getDispId, getMethodDispatch and putMethodDispatch into a separate entity
- * since they really do not interact with the CompilingClassLoader
- * functionality.
+ * since they really do not interact with the CompilingClassLoader
+ * functionality.
*/
public final class CompilingClassLoader extends ClassLoader {
@@ -31,6 +45,23 @@
private final class DispatchClassInfoOracle {
/**
+ * Class identifier to DispatchClassInfo mapping.
+ */
+ private final ArrayList classIdToClassInfo = new ArrayList();
+
+ /**
+ * Binary or source class name to DispatchClassInfo map.
+ */
+ private final Map classNameToClassInfo = new HashMap();
+
+ /**
+ * Class to ClassInfo map - this is only necessary to make sure that we have
+ * only only {@link DispatchClassInfo} for all of the different permutations
+ * of binary and source name combinations.
+ */
+ private final Map classToClassInfo = new HashMap();
+
+ /**
* Clears out the contents of this oracle.
*/
public synchronized void clear() {
@@ -165,11 +196,9 @@
* @return {@link DispatchClassInfo} associated with the binary or source
* class name; null if there is none
*/
- private DispatchClassInfo getClassInfoFromClassName(
- String className) {
+ private DispatchClassInfo getClassInfoFromClassName(String className) {
- DispatchClassInfo dispClassInfo = (DispatchClassInfo) classNameToClassInfo
- .get(className);
+ DispatchClassInfo dispClassInfo = (DispatchClassInfo) classNameToClassInfo.get(className);
if (dispClassInfo != null) {
// return the cached value
return dispClassInfo;
@@ -215,25 +244,16 @@
private int synthesizeDispId(int classId, int memberId) {
return (classId << 16) | memberId;
}
-
- /**
- * Class identifier to DispatchClassInfo mapping.
- */
- private final ArrayList classIdToClassInfo = new ArrayList();
-
- /**
- * Binary or source class name to DispatchClassInfo map.
- */
- private final Map classNameToClassInfo = new HashMap();
-
- /**
- * Class to ClassInfo map - this is only necessary to make sure that we have
- * only only {@link DispatchClassInfo} for all of the different permutations
- * of binary and source name combinations.
- */
- private final Map classToClassInfo = new HashMap();
}
+ private final ByteCodeCompiler compiler;
+
+ private final DispatchClassInfoOracle dispClassInfoOracle = new DispatchClassInfoOracle();
+
+ private final TreeLogger logger;
+
+ private final Map methodToDispatch = new HashMap();
+
public CompilingClassLoader(TreeLogger logger, ByteCodeCompiler compiler)
throws UnableToCompleteException {
super(null);
@@ -370,9 +390,4 @@
return false;
}
-
- private final ByteCodeCompiler compiler;
- private final DispatchClassInfoOracle dispClassInfoOracle = new DispatchClassInfoOracle();
- private final TreeLogger logger;
- private final Map methodToDispatch = new HashMap();
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/DialogBase.java b/dev/core/src/com/google/gwt/dev/shell/DialogBase.java
index 363f07d..28ccb3a 100644
--- a/dev/core/src/com/google/gwt/dev/shell/DialogBase.java
+++ b/dev/core/src/com/google/gwt/dev/shell/DialogBase.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.dev.GWTShell;
@@ -20,18 +34,7 @@
public abstract class DialogBase extends Dialog implements DisposeListener {
-/**
- * Pops up a confirm/cancel dialog.
- */
- public static boolean confirmAction(Shell shell, String msg, String msgTitle) {
- MessageBox msgBox = new MessageBox(shell, SWT.ICON_WARNING
- | SWT.YES | SWT.NO);
- msgBox.setText(msgTitle);
- msgBox.setMessage(msg);
- return msgBox.open() == SWT.YES;
- }
-
-private class Buttons extends GridPanel {
+ private class Buttons extends GridPanel {
public Buttons(Composite parent) {
super(parent, SWT.NONE, hasCancel ? 2 : 1, true);
@@ -76,6 +79,33 @@
}
}
+ /**
+ * Pops up a confirm/cancel dialog.
+ */
+ public static boolean confirmAction(Shell shell, String msg, String msgTitle) {
+ MessageBox msgBox = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES
+ | SWT.NO);
+ msgBox.setText(msgTitle);
+ msgBox.setMessage(msg);
+ return msgBox.open() == SWT.YES;
+ }
+
+ private Button cancelButton;
+
+ private boolean cancelled = true;
+
+ private boolean hasCancel;
+
+ private boolean hasOk;
+
+ private int minHeight;
+
+ private int minWidth;
+
+ private Button okButton;
+
+ private Shell shell;
+
public DialogBase(Shell parent, int minWidth, int minHeight) {
this(parent, minWidth, minHeight, true, true);
}
@@ -100,7 +130,7 @@
public boolean open(boolean autoSize) {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL
- | SWT.RESIZE);
+ | SWT.RESIZE);
shell.setImages(GWTShell.getIcons());
shell.setText(getText());
shell.setLayout(new FillLayout());
@@ -180,13 +210,4 @@
protected void setOkEnabled(boolean enabled) {
okButton.setEnabled(enabled);
}
-
- private Button cancelButton;
- private boolean cancelled = true;
- private boolean hasCancel;
- private boolean hasOk;
- private int minHeight;
- private int minWidth;
- private Button okButton;
- private Shell shell;
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/DispatchClassInfo.java b/dev/core/src/com/google/gwt/dev/shell/DispatchClassInfo.java
index ff91481..c9e5b88 100644
--- a/dev/core/src/com/google/gwt/dev/shell/DispatchClassInfo.java
+++ b/dev/core/src/com/google/gwt/dev/shell/DispatchClassInfo.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import java.lang.reflect.Field;
@@ -13,6 +27,14 @@
*/
public class DispatchClassInfo {
+ private Class cls;
+
+ private final int clsId;
+
+ private ArrayList memberById;
+
+ private HashMap memberIdByName;
+
public DispatchClassInfo(Class cls, int classId) {
this.cls = cls;
clsId = classId;
@@ -93,7 +115,7 @@
return "D";
} else if (type.equals(byte.class)) {
return "B";
- } else {
+ } else {
throw new RuntimeException("Unexpected primitive type: "
+ type.getName());
}
@@ -116,19 +138,19 @@
e.printStackTrace();
} catch (NoSuchMethodException e) {
/*
- * Interfaces do not automatically inherit toString() implicitly. If they
- * have not defined a toString() method then we will pick the one from
- * java.lang.Object::toString() method and use that at slot zero.
+ * Interfaces do not automatically inherit toString() implicitly. If
+ * they have not defined a toString() method then we will pick the one
+ * from java.lang.Object::toString() method and use that at slot zero.
*
* TODO(mmendez): How should we handle the case where a user writes JSNI
- * code to interact with an instance that is typed as a particular
- * interface? Should a user write JSNI code as follows:
- *
- * x.@com.google.gwt.HasFocus::equals(Ljava/lang/Object;)(y)
- *
+ * code to interact with an instance that is typed as a particular
+ * interface? Should a user write JSNI code as follows:
+ *
+ * x.@com.google.gwt.HasFocus::equals(Ljava/lang/Object;)(y)
+ *
* or
*
- * x.@java.lang.Object::equals(Ljava/lang/Object;)(y)
+ * x.@java.lang.Object::equals(Ljava/lang/Object;)(y)
*/
if (cls.isInterface()) {
try {
@@ -137,10 +159,10 @@
e1.printStackTrace();
}
} else {
- e.printStackTrace();
+ e.printStackTrace();
}
}
-
+
memberIdByName = new HashMap();
lazyInitTargetMembersUsingReflectionHelper(cls);
}
@@ -152,7 +174,7 @@
if (superclass != null) {
lazyInitTargetMembersUsingReflectionHelper(superclass);
}
-
+
// Get the methods on this class/interface.
//
Method[] methods = targetClass.getDeclaredMethods();
@@ -169,12 +191,4 @@
addMember(fields[i], fields[i].getName());
}
}
-
- private Class cls;
-
- private final int clsId;
-
- private ArrayList memberById;
-
- private HashMap memberIdByName;
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/GWTShellServlet.java b/dev/core/src/com/google/gwt/dev/shell/GWTShellServlet.java
index d6a6b31..1dc3f54 100644
--- a/dev/core/src/com/google/gwt/dev/shell/GWTShellServlet.java
+++ b/dev/core/src/com/google/gwt/dev/shell/GWTShellServlet.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
@@ -34,14 +48,11 @@
*/
public class GWTShellServlet extends HttpServlet {
- /**
- * When the GWT bootstrap JavaScript starts in hosted mode, it appends this
- * query param to the url for the nocache file so that this servlet can
- * generate one on-the-fly.
- */
- private static final String HOSTED_MODE_QUERY_PARAM = "h";
-
private static class RequestParts {
+ public final String moduleName;
+
+ public final String partialPath;
+
public RequestParts(HttpServletRequest request)
throws UnableToCompleteException {
String pathInfo = request.getPathInfo();
@@ -59,11 +70,31 @@
}
throw new UnableToCompleteException();
}
-
- public final String moduleName;
- public final String partialPath;
}
+ /**
+ * When the GWT bootstrap JavaScript starts in hosted mode, it appends this
+ * query param to the url for the nocache file so that this servlet can
+ * generate one on-the-fly.
+ */
+ private static final String HOSTED_MODE_QUERY_PARAM = "h";
+
+ private final Map loadedModulesByName = new HashMap();
+
+ private final Map loadedServletsByClassName = new HashMap();
+
+ private final Map modulesByServletPath = new HashMap();
+
+ private final Map mimeTypes = new HashMap();
+
+ private int nextRequestId;
+
+ private File outDir;
+
+ private final Object requestIdLock = new Object();
+
+ private TreeLogger topLogger;
+
public GWTShellServlet() {
initMimeTypes();
}
@@ -100,7 +131,7 @@
parts = new RequestParts(request);
} catch (UnableToCompleteException e) {
sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND,
- "Don't know what to do with this URL: '" + pathInfo + "'");
+ "Don't know what to do with this URL: '" + pathInfo + "'");
return;
}
@@ -135,7 +166,7 @@
// Branch the logger in case we decide to log more below.
logger = logger.branch(TreeLogger.TRACE, "Request " + id + ": " + url,
- null);
+ null);
}
String servletClassName = null;
@@ -179,19 +210,19 @@
if (servletClassName != null) {
TreeLogger branch = logger.branch(TreeLogger.WARN,
- "Use of deprecated hosted mode servlet path mapping", null);
+ "Use of deprecated hosted mode servlet path mapping", null);
branch.log(
- TreeLogger.WARN,
- "The client code is invoking the servlet with a URL that is not module-relative: "
- + path, null);
+ TreeLogger.WARN,
+ "The client code is invoking the servlet with a URL that is not module-relative: "
+ + path, null);
branch.log(
- TreeLogger.WARN,
- "Prepend GWT.getModuleBaseURL() to the URL in client code to create a module-relative URL: /"
- + moduleDef.getName() + path, null);
+ TreeLogger.WARN,
+ "Prepend GWT.getModuleBaseURL() to the URL in client code to create a module-relative URL: /"
+ + moduleDef.getName() + path, null);
branch.log(
- TreeLogger.WARN,
- "Using module-relative URLs ensures correct URL-independent behavior in external servlet containers",
- null);
+ TreeLogger.WARN,
+ "Using module-relative URLs ensures correct URL-independent behavior in external servlet containers",
+ null);
}
// Fall-through below, where we check servletClassName.
@@ -207,8 +238,9 @@
if (delegatee == null) {
logger.log(TreeLogger.ERROR, "Unable to dispatch request", null);
sendErrorResponse(response,
- HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
- "Unable to find/load mapped servlet class '" + servletClassName + "'");
+ HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ "Unable to find/load mapped servlet class '" + servletClassName
+ + "'");
return;
}
@@ -233,14 +265,14 @@
if ("favicon.ico".equalsIgnoreCase(parts.moduleName)) {
sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND,
- "Icon not available");
+ "Icon not available");
return;
}
// Generate a generic empty host page.
//
String msg = "The development shell servlet received a request to generate a host page for module '"
- + parts.moduleName + "' ";
+ + parts.moduleName + "' ";
logger = logger.branch(TreeLogger.TRACE, msg, null);
@@ -249,8 +281,8 @@
getModuleDef(logger, parts.moduleName);
} catch (UnableToCompleteException e) {
sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND,
- "Unable to find/load module '" + parts.moduleName
- + "' (see server log for details)");
+ "Unable to find/load module '" + parts.moduleName
+ + "' (see server log for details)");
return;
}
@@ -290,7 +322,7 @@
// Create a logger branch for this request.
String msg = "The development shell servlet received a request for '"
- + partialPath + "' in module '" + moduleName + "' ";
+ + partialPath + "' in module '" + moduleName + "' ";
logger = logger.branch(TreeLogger.TRACE, msg, null);
// If the request is of the form ".../moduleName.nocache.html[?...]", then
@@ -339,8 +371,8 @@
}
} catch (UnableToCompleteException e) {
sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND,
- "Cannot find resource '" + partialPath
- + "' in the public path of module '" + moduleName + "'");
+ "Cannot find resource '" + partialPath
+ + "' in the public path of module '" + moduleName + "'");
return;
}
@@ -378,12 +410,12 @@
response.setStatus(HttpServletResponse.SC_OK);
long now = new Date().getTime();
response.setHeader(HttpHeaders.DATE,
- HttpHeaders.toInternetDateFormat(now));
+ HttpHeaders.toInternetDateFormat(now));
response.setContentType(mimeType);
String lastModifiedStr = HttpHeaders.toInternetDateFormat(lastModified);
response.setHeader(HttpHeaders.LAST_MODIFIED, lastModifiedStr);
- final long JAN_2_1980 = 315637200000L;
- String inThePastStr = HttpHeaders.toInternetDateFormat(JAN_2_1980);
+ final long jan2nd1980 = 315637200000L;
+ String inThePastStr = HttpHeaders.toInternetDateFormat(jan2nd1980);
response.setHeader(HttpHeaders.EXPIRES, inThePastStr);
// Send the bytes. To keep it simple, we don't compute the length.
@@ -453,11 +485,11 @@
String[] servletPaths = moduleDef.getServletPaths();
for (int i = 0; i < servletPaths.length; i++) {
ModuleDef oldDef = (ModuleDef) modulesByServletPath.put(
- servletPaths[i], moduleDef);
+ servletPaths[i], moduleDef);
if (oldDef != null) {
logger.log(TreeLogger.WARN, "Undefined behavior: Servlet path "
- + servletPaths[i] + " conflicts in modules "
- + moduleDef.getName() + " and " + oldDef.getName(), null);
+ + servletPaths[i] + " conflicts in modules "
+ + moduleDef.getName() + " and " + oldDef.getName(), null);
}
}
// END BACKWARD COMPATIBILITY
@@ -713,9 +745,9 @@
Class servletClass = Class.forName(className);
Object newInstance = servletClass.newInstance();
if (!(newInstance instanceof HttpServlet)) {
- logger.log(TreeLogger.ERROR, "Not compatible with HttpServlet: "
- + className + " (does your service extend RemoteServiceServlet?)",
- null);
+ logger.log(TreeLogger.ERROR,
+ "Not compatible with HttpServlet: " + className
+ + " (does your service extend RemoteServiceServlet?)", null);
return null;
}
@@ -741,13 +773,4 @@
return null;
}
}
-
- private final Map loadedModulesByName = new HashMap();
- private final Map loadedServletsByClassName = new HashMap();
- private final Map modulesByServletPath = new HashMap();
- private final Map mimeTypes = new HashMap();
- private int nextRequestId;
- private File outDir;
- private final Object requestIdLock = new Object();
- private TreeLogger topLogger;
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/GridPanel.java b/dev/core/src/com/google/gwt/dev/shell/GridPanel.java
index 7892149..fb06ab7 100644
--- a/dev/core/src/com/google/gwt/dev/shell/GridPanel.java
+++ b/dev/core/src/com/google/gwt/dev/shell/GridPanel.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import org.eclipse.swt.SWT;
@@ -9,60 +23,71 @@
public class GridPanel extends Composite {
- public GridPanel(Composite parent, int style, int numCols, boolean equalWidthCols, int marginWidth, int marginHeight) {
- super(parent, style);
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = numCols;
- gridLayout.makeColumnsEqualWidth = equalWidthCols;
- gridLayout.marginWidth = marginWidth;
- gridLayout.marginHeight = marginHeight;
- gridLayout.horizontalSpacing = 1;
- gridLayout.verticalSpacing = 1;
- setLayout(gridLayout);
+ protected static final int FILL = GridData.FILL;
+
+ protected static final int CENTER = GridData.CENTER;
+
+ protected static final int MIDDLE = GridData.CENTER;
+
+ protected static final int LEFT = GridData.BEGINNING;
+
+ protected static final int RIGHT = GridData.END;
+
+ protected static final int TOP = GridData.BEGINNING;
+ protected static final int BOTTOM = GridData.END;
+
+ public GridPanel(Composite parent, int style, int numCols,
+ boolean equalWidthCols) {
+ this(parent, style, numCols, equalWidthCols, 5, 5);
+ }
+
+ public GridPanel(Composite parent, int style, int numCols,
+ boolean equalWidthCols, int marginWidth, int marginHeight) {
+ super(parent, style);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = numCols;
+ gridLayout.makeColumnsEqualWidth = equalWidthCols;
+ gridLayout.marginWidth = marginWidth;
+ gridLayout.marginHeight = marginHeight;
+ gridLayout.horizontalSpacing = 1;
+ gridLayout.verticalSpacing = 1;
+ setLayout(gridLayout);
+ }
+
+ protected GridData getGridData(Control control) {
+ GridData gridData = (GridData) control.getLayoutData();
+ if (gridData == null) {
+ gridData = new GridData();
+ control.setLayoutData(gridData);
+ }
+ return gridData;
+ }
+
+ protected GridData setGridData(Control control, int rowSpan, int colSpan,
+ int hAlign, int vAlign, boolean hGrab, boolean vGrab) {
+ return setGridData(control, rowSpan, colSpan, hAlign, vAlign, hGrab, vGrab,
+ SWT.DEFAULT, SWT.DEFAULT);
+ }
+
+ protected GridData setGridData(Control control, int rowSpan, int colSpan,
+ int hAlign, int vAlign, boolean hGrab, boolean vGrab, int widthHint,
+ int heightHint) {
+ GridData gridData = getGridData(control);
+ gridData.horizontalSpan = colSpan;
+ gridData.verticalSpan = rowSpan;
+ gridData.horizontalAlignment = hAlign;
+ gridData.verticalAlignment = vAlign;
+ gridData.grabExcessHorizontalSpace = hGrab;
+ gridData.grabExcessVerticalSpace = vGrab;
+ if (heightHint != SWT.DEFAULT) {
+ gridData.heightHint = heightHint;
}
- public GridPanel(Composite parent, int style, int numCols, boolean equalWidthCols) {
- this(parent, style, numCols, equalWidthCols, 5, 5);
+ if (widthHint != SWT.DEFAULT) {
+ gridData.widthHint = widthHint;
}
- protected GridData getGridData(Control control) {
- GridData gridData = (GridData)control.getLayoutData();
- if (gridData == null) {
- gridData = new GridData();
- control.setLayoutData(gridData);
- }
- return gridData;
- }
-
- protected GridData setGridData(Control control, int rowSpan, int colSpan, int hAlign, int vAlign, boolean hGrab, boolean vGrab) {
- return setGridData(control, rowSpan, colSpan, hAlign, vAlign, hGrab, vGrab, SWT.DEFAULT, SWT.DEFAULT);
- }
-
- protected GridData setGridData(Control control, int rowSpan, int colSpan, int hAlign, int vAlign, boolean hGrab, boolean vGrab, int widthHint, int heightHint) {
- GridData gridData = getGridData(control);
- gridData.horizontalSpan = colSpan;
- gridData.verticalSpan = rowSpan;
- gridData.horizontalAlignment = hAlign;
- gridData.verticalAlignment = vAlign;
- gridData.grabExcessHorizontalSpace = hGrab;
- gridData.grabExcessVerticalSpace = vGrab;
- if (heightHint != SWT.DEFAULT) {
- gridData.heightHint = heightHint;
- }
-
- if (widthHint != SWT.DEFAULT) {
- gridData.widthHint = widthHint;
- }
-
- control.setLayoutData(gridData);
- return gridData;
- }
-
- protected static final int FILL = GridData.FILL;
- protected static final int CENTER = GridData.CENTER;
- protected static final int MIDDLE = GridData.CENTER;
- protected static final int LEFT = GridData.BEGINNING;
- protected static final int RIGHT = GridData.END;
- protected static final int TOP = GridData.BEGINNING;
- protected static final int BOTTOM = GridData.END;
+ control.setLayoutData(gridData);
+ return gridData;
+ }
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/Handle.java b/dev/core/src/com/google/gwt/dev/shell/Handle.java
index 1bf5983..cb4ad56 100644
--- a/dev/core/src/com/google/gwt/dev/shell/Handle.java
+++ b/dev/core/src/com/google/gwt/dev/shell/Handle.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import java.lang.reflect.Constructor;
@@ -24,24 +38,14 @@
private static Object toBeReleasedLock = new Object();
private static Handle sImpl;
-
- protected Handle() {
- if (sImpl != null) {
- throw new RuntimeException("More than one Handle class!");
- }
- sImpl = this;
- }
- protected abstract void lockPtr(int ptr);
- protected abstract void unlockPtr(int ptr);
-
public static Object createHandle(Class type, int ptr) {
try {
checkThread();
- Constructor ctor = type.getDeclaredConstructor(new Class[]{Integer.TYPE});
+ Constructor ctor = type.getDeclaredConstructor(new Class[] {Integer.TYPE});
ctor.setAccessible(true);
- Object handle = ctor.newInstance(new Object[]{new Integer(ptr)});
+ Object handle = ctor.newInstance(new Object[] {new Integer(ptr)});
sImpl.lockPtr(ptr);
return handle;
} catch (InstantiationException e) {
@@ -59,6 +63,18 @@
}
}
+ /**
+ * Moves this ptr into a queue of COM objects that are ready to be released.
+ */
+ public static void enqueuePtr(int opaque) {
+ // Add to the queue to be released by the main thread later.
+ //
+ Integer intOpaque = new Integer(opaque);
+ synchronized (toBeReleasedLock) {
+ toBeReleased.add(intOpaque);
+ }
+ }
+
public static int getPtrFromHandle(Object handle) {
try {
checkThread();
@@ -67,7 +83,7 @@
while (handleClass != null && !handleClass.getName().equals(HANDLE_CLASS)) {
handleClass = handleClass.getSuperclass();
}
-
+
if (handleClass == null) {
throw new RuntimeException("Error reading handle");
}
@@ -104,18 +120,6 @@
}
/**
- * Moves this ptr into a queue of COM objects that are ready to be released.
- */
- public static void enqueuePtr(int opaque) {
- // Add to the queue to be released by the main thread later.
- //
- Integer intOpaque = new Integer(opaque);
- synchronized (toBeReleasedLock) {
- toBeReleased.add(intOpaque);
- }
- }
-
- /**
* Ensures that the current thread is actually the UI thread.
*/
private static synchronized void checkThread() {
@@ -125,4 +129,15 @@
throw new RuntimeException("This object has permanent thread affinity.");
}
}
+
+ protected Handle() {
+ if (sImpl != null) {
+ throw new RuntimeException("More than one Handle class!");
+ }
+ sImpl = this;
+ }
+
+ protected abstract void lockPtr(int ptr);
+
+ protected abstract void unlockPtr(int ptr);
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/HeaderBarBase.java b/dev/core/src/com/google/gwt/dev/shell/HeaderBarBase.java
index 76cdfa4..4eb1678 100644
--- a/dev/core/src/com/google/gwt/dev/shell/HeaderBarBase.java
+++ b/dev/core/src/com/google/gwt/dev/shell/HeaderBarBase.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import org.eclipse.swt.SWT;
@@ -15,13 +29,14 @@
import org.eclipse.swt.widgets.ToolItem;
/**
- * Base class for <code>Composites</code> that contain <code>ToolItem</code> entities.
+ * Base class for <code>Composites</code> that contain <code>ToolItem</code>
+ * entities.
*/
public class HeaderBarBase extends Composite implements DisposeListener {
-
+
private final Color bgColor;
private final ToolBar toolBar;
-
+
public HeaderBarBase(Composite parent) {
super(parent, SWT.NONE);
@@ -64,14 +79,10 @@
logoLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
}
- public void widgetDisposed(DisposeEvent e) {
- bgColor.dispose();
- }
-
public ToolBar getToolBar() {
return toolBar;
}
-
+
public ToolItem newItem(String imageName, String label, String tooltip) {
ToolItem item = new ToolItem(toolBar, SWT.PUSH);
item.setImage(LowLevel.loadImage(imageName));
@@ -81,8 +92,12 @@
item.setWidth(60);
return item;
}
-
+
public void newSeparator() {
new ToolItem(toolBar, SWT.SEPARATOR);
}
+
+ public void widgetDisposed(DisposeEvent e) {
+ bgColor.dispose();
+ }
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/HostedModeSourceOracle.java b/dev/core/src/com/google/gwt/dev/shell/HostedModeSourceOracle.java
index f86610a..9e79588 100644
--- a/dev/core/src/com/google/gwt/dev/shell/HostedModeSourceOracle.java
+++ b/dev/core/src/com/google/gwt/dev/shell/HostedModeSourceOracle.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
@@ -14,8 +28,8 @@
*/
public class HostedModeSourceOracle extends StandardSourceOracle {
- private final CompilationUnitProvider CU_Meta = new StaticCompilationUnitProvider(
- "com.google.gwt.core.client", "GWT", null) {
+ private final CompilationUnitProvider cuMeta = new StaticCompilationUnitProvider(
+ "com.google.gwt.core.client", "GWT", null) {
public char[] getSource() {
StringBuffer sb = new StringBuffer();
sb.append("package com.google.gwt.core.client;\n");
@@ -35,20 +49,20 @@
sb.append(" log(\"Uncaught exception escaped\", e);\n");
sb.append(" }\n");
sb.append(" };\n");
-
+
// Implement getUncaughtExceptionHandler()
//
- sb.append(" public static UncaughtExceptionHandler getUncaughtExceptionHandler() {\n");
- sb.append(" return sUncaughtExceptionHandler;\n");
+ sb.append(" public static UncaughtExceptionHandler getUncaughtExceptionHandler() {\n");
+ sb.append(" return sUncaughtExceptionHandler;\n");
sb.append(" }\n");
// Implement setUncaughtExceptionHandler()
//
- sb.append(" public static void setUncaughtExceptionHandler(\n");
- sb.append(" UncaughtExceptionHandler handler) {\n");
- sb.append(" sUncaughtExceptionHandler = handler;\n");
+ sb.append(" public static void setUncaughtExceptionHandler(\n");
+ sb.append(" UncaughtExceptionHandler handler) {\n");
+ sb.append(" sUncaughtExceptionHandler = handler;\n");
sb.append(" }\n");
-
+
// Proxy create().
//
sb.append(" public static Object create(Class classLiteral) {\n");
@@ -79,7 +93,7 @@
sb.append(moduleName);
sb.append("\";\n");
sb.append(" }\n");
-
+
// Proxy getModuleBaseURL() to the Impl class.
//
sb.append(" public static String getModuleBaseURL() {\n");
@@ -92,12 +106,16 @@
sb.append(ShellGWT.class.getName());
sb.append(".log(message, e);\n");
sb.append(" }\n");
-
+
sb.append("}\n");
return sb.toString().toCharArray();
}
};
+ private final JsniInjector injector;
+
+ private final String moduleName;
+
public HostedModeSourceOracle(TypeOracle typeOracle, String moduleName) {
super(typeOracle);
this.moduleName = moduleName;
@@ -119,7 +137,7 @@
// the web mode version, so here we substitute the hosted mode version.
//
if (typeName.equals("com.google.gwt.core.client.GWT")) {
- return CU_Meta;
+ return cuMeta;
}
// Otherwise, it's a regular translatable type, but we want to make sure
@@ -129,7 +147,4 @@
return jsnified;
}
-
- private final JsniInjector injector;
- private final String moduleName;
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/JavaDispatch.java b/dev/core/src/com/google/gwt/dev/shell/JavaDispatch.java
index f889b08..1ef43e1 100644
--- a/dev/core/src/com/google/gwt/dev/shell/JavaDispatch.java
+++ b/dev/core/src/com/google/gwt/dev/shell/JavaDispatch.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import java.lang.reflect.Field;
diff --git a/dev/core/src/com/google/gwt/dev/shell/JavaDispatchImpl.java b/dev/core/src/com/google/gwt/dev/shell/JavaDispatchImpl.java
index 6fc8482..8d9ce4c 100644
--- a/dev/core/src/com/google/gwt/dev/shell/JavaDispatchImpl.java
+++ b/dev/core/src/com/google/gwt/dev/shell/JavaDispatchImpl.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import java.lang.reflect.Field;
@@ -10,6 +24,20 @@
*/
public class JavaDispatchImpl implements JavaDispatch {
+ private final CompilingClassLoader classLoader;
+
+ private final Object target;
+
+ /**
+ * This constructor initializes a dispatcher for handling static members.
+ *
+ * @param ccl class loader to use for dispatching member access
+ */
+ public JavaDispatchImpl(CompilingClassLoader ccl) {
+ classLoader = ccl;
+ target = null;
+ }
+
/**
* This constructor initializes a dispatcher around a particular instance.
*
@@ -28,16 +56,6 @@
}
/**
- * This constructor initializes a dispatcher for handling static members.
- *
- * @param ccl class loader to use for dispatching member access
- */
- public JavaDispatchImpl(CompilingClassLoader ccl) {
- classLoader = ccl;
- target = null;
- }
-
- /**
* @param dispId the unique number of a field
* @return the field
*/
@@ -81,7 +99,7 @@
if (dispId < 0) {
return false;
}
-
+
return getMember(dispId) instanceof Field;
}
@@ -93,7 +111,7 @@
if (dispId < 0) {
return false;
}
-
+
return getMember(dispId) instanceof Method;
}
@@ -132,7 +150,4 @@
DispatchClassInfo clsInfo = classLoader.getClassInfoByDispId(dispId);
return clsInfo.getMember(dispId);
}
-
- private final CompilingClassLoader classLoader;
- private final Object target;
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/JavaScriptHost.java b/dev/core/src/com/google/gwt/dev/shell/JavaScriptHost.java
index 9b765c0..4d67523 100644
--- a/dev/core/src/com/google/gwt/dev/shell/JavaScriptHost.java
+++ b/dev/core/src/com/google/gwt/dev/shell/JavaScriptHost.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
/**
diff --git a/dev/core/src/com/google/gwt/dev/shell/JsniInjector.java b/dev/core/src/com/google/gwt/dev/shell/JsniInjector.java
index a02c08e..5c0ba42 100644
--- a/dev/core/src/com/google/gwt/dev/shell/JsniInjector.java
+++ b/dev/core/src/com/google/gwt/dev/shell/JsniInjector.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
@@ -38,6 +52,10 @@
static final String PKG_STRING = "java.lang";
static final String CLS_STRING = "String";
+ public final JClassType javaLangString;
+
+ public final JClassType javaScriptObject;
+
public CoreTypes(TreeLogger logger) throws UnableToCompleteException {
javaScriptObject = getCoreType(logger, PKG_JSOBJECT, CLS_JSOBJECT);
javaLangString = getCoreType(logger, PKG_STRING, CLS_STRING);
@@ -53,15 +71,18 @@
throw new UnableToCompleteException();
}
}
-
- public final JClassType javaLangString;
- public final JClassType javaScriptObject;
}
/**
* A chunk of replacement text and where to put it.
*/
private static class Replacement implements Comparable {
+ public final int end;
+
+ public final int start;
+
+ public final char[] text;
+
public Replacement(int start, int end, char[] text) {
this.start = start;
this.end = end;
@@ -80,12 +101,14 @@
return 0;
}
}
-
- public final int end;
- public final int start;
- public final char[] text;
}
+ private final TypeOracle oracle;
+
+ private CoreTypes coreTypes;
+
+ private final Map parsedJsByMethod = new IdentityHashMap();
+
public JsniInjector(TypeOracle oracle) {
this.oracle = oracle;
}
@@ -94,7 +117,7 @@
CompilationUnitProvider cup) throws UnableToCompleteException {
logger = logger.branch(TreeLogger.SPAM,
- "Checking for JavaScript native methods", null);
+ "Checking for JavaScript native methods", null);
// Make sure the core types exist.
//
@@ -127,7 +150,7 @@
// No changes were made, so we return the original.
//
logger.log(TreeLogger.SPAM, "No JavaScript native methods were found",
- null);
+ null);
return cup;
}
}
@@ -157,21 +180,21 @@
JParameter[] params = method.getParameters();
String paramNamesArray = getParamNamesArrayExpr(params);
- final String TRY = "try ";
- final String CATCH = " catch (e) {\\n"
- + " __static[\\\"@"
- + Jsni.JAVASCRIPTHOST_NAME
- + "::exceptionCaught"
- + "(ILjava/lang/String;Ljava/lang/String;)\\\"]"
- + "((e && e.number) ? e.number : 0, e ? e.name : null , e ? e.message : null);\\n"
- + "}\\n";
+ final String jsTry = "try ";
+ final String jsCatch = " catch (e) {\\n"
+ + " __static[\\\"@"
+ + Jsni.JAVASCRIPTHOST_NAME
+ + "::exceptionCaught"
+ + "(ILjava/lang/String;Ljava/lang/String;)\\\"]"
+ + "((e && e.number) ? e.number : 0, e ? e.name : null , e ? e.message : null);\\n"
+ + "}\\n";
// Surround the original JS body statements with a try/catch so that
// we can map JavaScript exceptions back into Java.
// Note that the method body itself will print curly braces, so we don't
// need them around the try/catch.
//
- String js = TRY + Jsni.generateEscapedJavaScript(jsniBody) + CATCH;
+ String js = jsTry + Jsni.generateEscapedJavaScript(jsniBody) + jsCatch;
String jsniSig = Jsni.getJsniSignature(method);
// figure out starting line number
@@ -179,8 +202,8 @@
int line = Jsni.countNewlines(source, 0, bodyStart) + 1;
sb.append(" " + Jsni.JAVASCRIPTHOST_NAME + ".createNative(\""
- + escapedFile + "\", " + line + ", " + "\"@" + jsniSig + "\", "
- + paramNamesArray + ", \"" + js + "\");");
+ + escapedFile + "\", " + line + ", " + "\"@" + jsniSig + "\", "
+ + paramNamesArray + ", \"" + js + "\");");
}
sb.append("}");
return sb.toString().toCharArray();
@@ -203,7 +226,7 @@
}
String methodDecl = method.getReadableDeclaration(false, true, false,
- false, false);
+ false, false);
sb.append(methodDecl + " {");
@@ -218,7 +241,7 @@
//
String returnTypeName = returnType.getQualifiedSourceName();
sb.append("return (" + returnTypeName + ")" + Jsni.JAVASCRIPTHOST_NAME
- + ".invokeNativeHandle");
+ + ".invokeNativeHandle");
} else if (null != (primType = returnType.isPrimitive())) {
// Primitives have special overloads.
//
@@ -293,7 +316,7 @@
if (i > 0) {
sb.append(", ");
}
-
+
JParameter param = params[i];
sb.append('\"');
sb.append(param.getName());
@@ -349,7 +372,7 @@
// Parse it.
//
String js = new String(source, interval.start, interval.end
- - interval.start);
+ - interval.start);
int startLine = Jsni.countNewlines(source, 0, interval.start) + 1;
JsBlock body = Jsni.parseAsFunctionBody(logger, js, loc, startLine);
@@ -362,11 +385,11 @@
final int declEnd = method.getDeclEnd();
int expectedHeaderLines = Jsni.countNewlines(source, declStart,
- interval.start);
+ interval.start);
int expectedBodyLines = Jsni.countNewlines(source, interval.start,
- interval.end);
+ interval.end);
String newDecl = genNonNativeVersionOfJsniMethod(method,
- expectedHeaderLines, expectedBodyLines);
+ expectedHeaderLines, expectedBodyLines);
final char[] newSource = newDecl.toCharArray();
changes.add(new Replacement(declStart, declEnd, newSource));
@@ -374,7 +397,7 @@
} else {
// report error
String msg = "No JavaScript body found for native method '" + method
- + "' in type '" + type + "'";
+ + "' in type '" + type + "'";
logger.log(TreeLogger.ERROR, msg, null);
throw new UnableToCompleteException();
}
@@ -386,7 +409,7 @@
patched = (JMethod[]) patchedMethods.toArray(patched);
TreeLogger branch = logger.branch(TreeLogger.SPAM, "Patched methods in '"
- + type.getQualifiedSourceName() + "'", null);
+ + type.getQualifiedSourceName() + "'", null);
for (int i = 0; i < patched.length; i++) {
branch.log(TreeLogger.SPAM, patched[i].getReadableDeclaration(), null);
@@ -407,8 +430,4 @@
changes.add(new Replacement(bodyStart, bodyStart, block));
}
}
-
- private final TypeOracle oracle;
- private CoreTypes coreTypes;
- private final Map parsedJsByMethod = new IdentityHashMap();
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/LowLevel.java b/dev/core/src/com/google/gwt/dev/shell/LowLevel.java
index 5bc02f8..1eb08f9 100644
--- a/dev/core/src/com/google/gwt/dev/shell/LowLevel.java
+++ b/dev/core/src/com/google/gwt/dev/shell/LowLevel.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.util.tools.Utility;
@@ -15,17 +29,62 @@
*/
public class LowLevel {
- /**
- * This class is not instantiable.
- */
- private LowLevel() {
- }
-
- public static final String PACKAGE_PATH = LowLevel.class.getPackage()
- .getName().replace('.', '/').concat("/");
+ public static final String PACKAGE_PATH = LowLevel.class.getPackage().getName().replace(
+ '.', '/').concat("/");
private static boolean sInitialized = false;
+ /**
+ * Clobbers a field on an object to which we do not have access.
+ */
+ public static void clobberFieldObjectValue(Class victimClass,
+ Object victimObject, String fieldName, Object value) {
+ Throwable rethrow = null;
+ try {
+ Field victimField = victimClass.getDeclaredField(fieldName);
+ victimField.setAccessible(true);
+ victimField.set(victimObject, value);
+ return;
+ } catch (IllegalArgumentException e) {
+ rethrow = e;
+ } catch (SecurityException e) {
+ rethrow = e;
+ } catch (IllegalAccessException e) {
+ rethrow = e;
+ } catch (NoSuchFieldException e) {
+ rethrow = e;
+ }
+ throw new RuntimeException("Unable to clobber field '" + fieldName
+ + "' from class " + victimClass.getName(), rethrow);
+ }
+
+ /**
+ * Clobbers a field on an object to which we do not have access.
+ */
+ public static void clobberFieldObjectValue(Object victim, String fieldName,
+ Object value) {
+ if (victim != null) {
+ clobberFieldObjectValue(victim.getClass(), victim, fieldName, value);
+ } else {
+ throw new NullPointerException("victim must not be null");
+ }
+ }
+
+ /**
+ * Deletes a global ref on the specified object, invalidating its handle.
+ */
+ public static void deleteGlobalRefInt(int globalRef) {
+ _deleteGlobalRefInt(globalRef);
+ }
+
+ /**
+ * Gets an environment variable. This is to replace the deprecated
+ * {@link System#getenv(java.lang.String)}.
+ */
+ public static String getEnv(String key) {
+ return _getEnv(key);
+ }
+
public static synchronized void init() {
if (!sInitialized) {
String libName = "gwt-ll";
@@ -72,57 +131,6 @@
}
/**
- * Clobbers a field on an object to which we do not have access.
- */
- public static void clobberFieldObjectValue(Class victimClass,
- Object victimObject, String fieldName, Object value) {
- Throwable rethrow = null;
- try {
- Field victimField = victimClass.getDeclaredField(fieldName);
- victimField.setAccessible(true);
- victimField.set(victimObject, value);
- return;
- } catch (IllegalArgumentException e) {
- rethrow = e;
- } catch (SecurityException e) {
- rethrow = e;
- } catch (IllegalAccessException e) {
- rethrow = e;
- } catch (NoSuchFieldException e) {
- rethrow = e;
- }
- throw new RuntimeException("Unable to clobber field '" + fieldName
- + "' from class " + victimClass.getName(), rethrow);
- }
-
- /**
- * Clobbers a field on an object to which we do not have access.
- */
- public static void clobberFieldObjectValue(Object victim, String fieldName,
- Object value) {
- if (victim != null) {
- clobberFieldObjectValue(victim.getClass(), victim, fieldName, value);
- } else {
- throw new NullPointerException("victim must not be null");
- }
- }
-
- /**
- * Deletes a global ref on the specified object, invalidating its handle.
- */
- public static void deleteGlobalRefInt(int globalRef) {
- _deleteGlobalRefInt(globalRef);
- }
-
- /**
- * Gets an environment variable. This is to replace the deprecated
- * {@link System#getenv(java.lang.String)}.
- */
- public static String getEnv(String key) {
- return _getEnv(key);
- }
-
- /**
* Creates a global ref on the specified object, returning its int handle.
*/
public static int newGlobalRefInt(Object o) {
@@ -157,7 +165,7 @@
rethrow = e;
}
throw new RuntimeException("Unable to snatch field '" + fieldName
- + "' from class " + victimClass.getName(), rethrow);
+ + "' from class " + victimClass.getName(), rethrow);
}
/**
@@ -179,4 +187,10 @@
private static native Object _objFromGlobalRefInt(int globalRef);
+ /**
+ * This class is not instantiable.
+ */
+ private LowLevel() {
+ }
+
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/Messages.java b/dev/core/src/com/google/gwt/dev/shell/Messages.java
index 1e2ca92..b13fc33 100644
--- a/dev/core/src/com/google/gwt/dev/shell/Messages.java
+++ b/dev/core/src/com/google/gwt/dev/shell/Messages.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
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 8d14423..e0c2835 100644
--- a/dev/core/src/com/google/gwt/dev/shell/ModuleSpace.java
+++ b/dev/core/src/com/google/gwt/dev/shell/ModuleSpace.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
@@ -15,13 +29,54 @@
*/
public abstract class ModuleSpace implements ShellJavaScriptHost {
- private final ModuleSpaceHost host;
+ protected static ThreadLocal sThrownJavaExceptionObject = new ThreadLocal();
+
+ protected static ThreadLocal sCaughtJavaExceptionObject = new ThreadLocal();
/**
* Logger is thread local.
*/
private static ThreadLocal threadLocalLogger = new ThreadLocal();
+ public static void setThrownJavaException(RuntimeException re) {
+ getLogger().log(TreeLogger.WARN, "Exception thrown into JavaScript", re);
+ sThrownJavaExceptionObject.set(re);
+ }
+
+ protected static RuntimeException createJavaScriptException(ClassLoader cl,
+ String name, String desc) {
+ Exception caught;
+ try {
+ Class javaScriptExceptionClass = Class.forName(
+ "com.google.gwt.core.client.JavaScriptException", true, cl);
+ Class string = String.class;
+ Constructor ctor = javaScriptExceptionClass.getDeclaredConstructor(new Class[] {
+ string, string});
+ return (RuntimeException) ctor.newInstance(new Object[] {name, desc});
+ } catch (InstantiationException e) {
+ caught = e;
+ } catch (IllegalAccessException e) {
+ caught = e;
+ } catch (SecurityException e) {
+ caught = e;
+ } catch (ClassNotFoundException e) {
+ caught = e;
+ } catch (NoSuchMethodException e) {
+ caught = e;
+ } catch (IllegalArgumentException e) {
+ caught = e;
+ } catch (InvocationTargetException e) {
+ caught = e;
+ }
+ throw new RuntimeException("Error creating JavaScriptException", caught);
+ }
+
+ protected static TreeLogger getLogger() {
+ return (TreeLogger) threadLocalLogger.get();
+ }
+
+ private final ModuleSpaceHost host;
+
protected ModuleSpace(final ModuleSpaceHost host) {
this.host = host;
TreeLogger hostLogger = host.getLogger();
@@ -32,11 +87,27 @@
// Tell the user-space JavaScript host object that we're done
//
clearJavaScriptHost();
-
+
// Clear out the class loader's cache
host.getClassLoader().clear();
}
+ public void ditchHandle(int opaque) {
+ Handle.enqueuePtr(opaque);
+ }
+
+ /**
+ * Allows client-side code to log to the tree logger.
+ */
+ public void log(String message, Throwable e) {
+ TreeLogger logger = host.getLogger();
+ TreeLogger.Type type = TreeLogger.INFO;
+ if (e != null) {
+ type = TreeLogger.ERROR;
+ }
+ logger.log(type, message, e);
+ }
+
/**
* Runs the module's user startup code.
*/
@@ -63,12 +134,11 @@
entryPointTypeName = entryPoints[i];
Object module = rebindAndCreate(entryPointTypeName);
Method onModuleLoad = module.getClass().getMethod("onModuleLoad",
- null);
+ null);
onModuleLoad.invoke(module, null);
}
} else {
- logger
- .log(
+ logger.log(
TreeLogger.WARN,
"The module has no entry points defined, so onModuleLoad() will never be called",
null);
@@ -84,9 +154,9 @@
caught = ((ExceptionInInitializerError) caught).getException();
}
- final String UNABLE_TO_LOAD_MESSAGE = "Unable to load module entry point class "
- + entryPointTypeName;
- logger.log(TreeLogger.ERROR, UNABLE_TO_LOAD_MESSAGE, caught);
+ final String unableToLoadMessage = "Unable to load module entry point class "
+ + entryPointTypeName;
+ logger.log(TreeLogger.ERROR, unableToLoadMessage, caught);
throw new UnableToCompleteException();
}
}
@@ -121,12 +191,97 @@
// initializers and other unusual places, which can obscure the problem.
//
String msg = "Failed to create an instance of '" + requestedClassName
- + "' via deferred binding ";
+ + "' via deferred binding ";
host.getLogger().log(TreeLogger.ERROR, msg, caught);
throw new UnableToCompleteException();
}
+ protected String createNativeMethodInjector(String jsniSignature,
+ String[] paramNames, String js) {
+ String newScript = "window[\"" + jsniSignature + "\"] = function(";
+
+ for (int i = 0; i < paramNames.length; ++i) {
+ if (i > 0) {
+ newScript += ", ";
+ }
+
+ newScript += paramNames[i];
+ }
+
+ newScript += ") { " + js + " };\n";
+ return newScript;
+ }
+
+ protected CompilingClassLoader getIsolatedClassLoader() {
+ return host.getClassLoader();
+ }
+
+ /**
+ * Injects the magic needed to resolve JSNI references from module-space.
+ */
+ protected abstract void initializeStaticDispatcher();
+
+ protected boolean isExceptionActive() {
+ return sCaughtJavaExceptionObject.get() != null;
+ }
+
+ protected String rebind(String sourceName) throws UnableToCompleteException {
+ try {
+ String result = host.rebind(host.getLogger(), sourceName);
+ if (result != null) {
+ return result;
+ } else {
+ return sourceName;
+ }
+ } catch (UnableToCompleteException e) {
+ String msg = "Deferred binding failed for '" + sourceName
+ + "'; expect subsequent failures";
+ host.getLogger().log(TreeLogger.ERROR, msg, e);
+ throw new UnableToCompleteException();
+ }
+ }
+
+ protected RuntimeException takeJavaException() {
+ RuntimeException re = (RuntimeException) sCaughtJavaExceptionObject.get();
+ sCaughtJavaExceptionObject.set(null);
+ return re;
+ }
+
+ /**
+ * Tricky one, this. Reaches over into this modules's JavaScriptHost class and
+ * sets its static 'host' field to be null.
+ *
+ * @see JavaScriptHost
+ */
+ private void clearJavaScriptHost() {
+ // Find the application's JavaScriptHost interface.
+ //
+ Throwable caught;
+ try {
+ final String jsHostClassName = JavaScriptHost.class.getName();
+ Class jsHostClass = Class.forName(jsHostClassName, true,
+ getIsolatedClassLoader());
+ final Class[] paramTypes = new Class[] {ShellJavaScriptHost.class};
+ Method setHostMethod = jsHostClass.getMethod("setHost", paramTypes);
+ setHostMethod.invoke(jsHostClass, new Object[] {null});
+ return;
+ } catch (ClassNotFoundException e) {
+ caught = e;
+ } catch (SecurityException e) {
+ caught = e;
+ } catch (NoSuchMethodException e) {
+ caught = e;
+ } catch (IllegalArgumentException e) {
+ caught = e;
+ } catch (IllegalAccessException e) {
+ caught = e;
+ } catch (InvocationTargetException e) {
+ caught = e.getTargetException();
+ }
+ throw new RuntimeException("Error unintializing JavaScriptHost", caught);
+ }
+
/**
* Handles loading a class that might be nested given a source type name.
*/
@@ -149,65 +304,6 @@
}
}
- public void ditchHandle(int opaque) {
- Handle.enqueuePtr(opaque);
- }
-
- protected String createNativeMethodInjector(String jsniSignature,
- String[] paramNames, String js) {
- String newScript = "window[\"" + jsniSignature + "\"] = function(";
-
- for (int i = 0; i < paramNames.length; ++i) {
- if (i > 0) {
- newScript += ", ";
- }
-
- newScript += paramNames[i];
- }
-
- newScript += ") { " + js + " };\n";
- return newScript;
- }
-
- /**
- * Injects the magic needed to resolve JSNI references from module-space.
- */
- protected abstract void initializeStaticDispatcher();
-
- /**
- * Tricky one, this. Reaches over into this modules's JavaScriptHost class and
- * sets its static 'host' field to be null.
- *
- * @see JavaScriptHost
- */
- private void clearJavaScriptHost() {
- // Find the application's JavaScriptHost interface.
- //
- Throwable caught;
- try {
- final String jsHostClassName = JavaScriptHost.class.getName();
- Class jsHostClass = Class.forName(jsHostClassName, true,
- getIsolatedClassLoader());
- final Class[] paramTypes = new Class[]{ShellJavaScriptHost.class};
- Method setHostMethod = jsHostClass.getMethod("setHost", paramTypes);
- setHostMethod.invoke(jsHostClass, new Object[]{null});
- return;
- } catch (ClassNotFoundException e) {
- caught = e;
- } catch (SecurityException e) {
- caught = e;
- } catch (NoSuchMethodException e) {
- caught = e;
- } catch (IllegalArgumentException e) {
- caught = e;
- } catch (IllegalAccessException e) {
- caught = e;
- } catch (InvocationTargetException e) {
- caught = e.getTargetException();
- }
- throw new RuntimeException("Error unintializing JavaScriptHost", caught);
- }
-
/**
* Tricky one, this. Reaches over into this modules's JavaScriptHost class and
* sets its static 'host' field to be this ModuleSpace instance.
@@ -221,10 +317,10 @@
try {
final String jsHostClassName = JavaScriptHost.class.getName();
Class jsHostClass = Class.forName(jsHostClassName, true,
- getIsolatedClassLoader());
- final Class[] paramTypes = new Class[]{ShellJavaScriptHost.class};
+ getIsolatedClassLoader());
+ final Class[] paramTypes = new Class[] {ShellJavaScriptHost.class};
Method setHostMethod = jsHostClass.getMethod("setHost", paramTypes);
- setHostMethod.invoke(jsHostClass, new Object[]{this});
+ setHostMethod.invoke(jsHostClass, new Object[] {this});
return;
} catch (ClassNotFoundException e) {
caught = e;
@@ -241,86 +337,4 @@
}
throw new RuntimeException("Error intializing JavaScriptHost", caught);
}
-
- protected static ThreadLocal sThrownJavaExceptionObject = new ThreadLocal();
- protected static ThreadLocal sCaughtJavaExceptionObject = new ThreadLocal();
-
- protected boolean isExceptionActive() {
- return sCaughtJavaExceptionObject.get() != null;
- }
-
- protected RuntimeException takeJavaException() {
- RuntimeException re = (RuntimeException) sCaughtJavaExceptionObject.get();
- sCaughtJavaExceptionObject.set(null);
- return re;
- }
-
- public static void setThrownJavaException(RuntimeException re) {
- getLogger().log(TreeLogger.WARN, "Exception thrown into JavaScript", re);
- sThrownJavaExceptionObject.set(re);
- }
-
- protected static RuntimeException createJavaScriptException(ClassLoader cl,
- String name, String desc) {
- Exception caught;
- try {
- Class javaScriptExceptionClass = Class.forName(
- "com.google.gwt.core.client.JavaScriptException", true, cl);
- Class string = String.class;
- Constructor ctor = javaScriptExceptionClass
- .getDeclaredConstructor(new Class[]{string, string});
- return (RuntimeException) ctor.newInstance(new Object[]{name, desc});
- } catch (InstantiationException e) {
- caught = e;
- } catch (IllegalAccessException e) {
- caught = e;
- } catch (SecurityException e) {
- caught = e;
- } catch (ClassNotFoundException e) {
- caught = e;
- } catch (NoSuchMethodException e) {
- caught = e;
- } catch (IllegalArgumentException e) {
- caught = e;
- } catch (InvocationTargetException e) {
- caught = e;
- }
- throw new RuntimeException("Error creating JavaScriptException", caught);
- }
-
- protected CompilingClassLoader getIsolatedClassLoader() {
- return host.getClassLoader();
- }
-
- protected static TreeLogger getLogger() {
- return (TreeLogger) threadLocalLogger.get();
- }
-
- protected String rebind(String sourceName) throws UnableToCompleteException {
- try {
- String result = host.rebind(host.getLogger(), sourceName);
- if (result != null) {
- return result;
- } else {
- return sourceName;
- }
- } catch (UnableToCompleteException e) {
- String msg = "Deferred binding failed for '" + sourceName
- + "'; expect subsequent failures";
- host.getLogger().log(TreeLogger.ERROR, msg, e);
- throw new UnableToCompleteException();
- }
- }
-
- /**
- * Allows client-side code to log to the tree logger.
- */
- public void log(String message, Throwable e) {
- TreeLogger logger = host.getLogger();
- TreeLogger.Type type = TreeLogger.INFO;
- if (e != null) {
- type = TreeLogger.ERROR;
- }
- logger.log(type, message, e);
- }
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/ModuleSpaceHost.java b/dev/core/src/com/google/gwt/dev/shell/ModuleSpaceHost.java
index 1544c29..61bbc32 100644
--- a/dev/core/src/com/google/gwt/dev/shell/ModuleSpaceHost.java
+++ b/dev/core/src/com/google/gwt/dev/shell/ModuleSpaceHost.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
diff --git a/dev/core/src/com/google/gwt/dev/shell/ModuleSpacePropertyOracle.java b/dev/core/src/com/google/gwt/dev/shell/ModuleSpacePropertyOracle.java
index 48cc548..1d89d94 100644
--- a/dev/core/src/com/google/gwt/dev/shell/ModuleSpacePropertyOracle.java
+++ b/dev/core/src/com/google/gwt/dev/shell/ModuleSpacePropertyOracle.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.BadPropertyValueException;
@@ -13,6 +27,12 @@
public class ModuleSpacePropertyOracle implements PropertyOracle {
+ private final Properties props;
+
+ private final ModuleSpace space;
+
+ private final Map prevAnswers = new HashMap();
+
public ModuleSpacePropertyOracle(Properties props, ModuleSpace space) {
this.space = space;
this.props = props;
@@ -32,7 +52,7 @@
// Don't know this property; that's not good.
//
throw new IllegalArgumentException("unknown property name: "
- + propertyName);
+ + propertyName);
}
String value;
@@ -81,12 +101,12 @@
// Invoke the property provider function in JavaScript.
//
value = space.invokeNativeString(scriptFnName, null, Empty.CLASSES,
- Empty.OBJECTS);
+ Empty.OBJECTS);
} catch (RuntimeException e) {
// Treat as an unknown value.
//
String msg = "Error while executing the JavaScript provider for property '"
- + propertyName + "'";
+ + propertyName + "'";
logger.log(TreeLogger.ERROR, msg, e);
throw new BadPropertyValueException(propertyName, "<failed to compute>");
}
@@ -103,8 +123,4 @@
private String makeScriptFnName(Property prop) {
return "prop$" + prop.getName();
}
-
- private final Properties props;
- private final ModuleSpace space;
- private final Map prevAnswers = new HashMap();
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/PlatformSpecific.java b/dev/core/src/com/google/gwt/dev/shell/PlatformSpecific.java
index e2c0817..74f9033 100644
--- a/dev/core/src/com/google/gwt/dev/shell/PlatformSpecific.java
+++ b/dev/core/src/com/google/gwt/dev/shell/PlatformSpecific.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
diff --git a/dev/core/src/com/google/gwt/dev/shell/ShellGWT.java b/dev/core/src/com/google/gwt/dev/shell/ShellGWT.java
index 0f68191..d16ea46 100644
--- a/dev/core/src/com/google/gwt/dev/shell/ShellGWT.java
+++ b/dev/core/src/com/google/gwt/dev/shell/ShellGWT.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
/**
diff --git a/dev/core/src/com/google/gwt/dev/shell/ShellJavaScriptHost.java b/dev/core/src/com/google/gwt/dev/shell/ShellJavaScriptHost.java
index 224d710..ebea2e4 100644
--- a/dev/core/src/com/google/gwt/dev/shell/ShellJavaScriptHost.java
+++ b/dev/core/src/com/google/gwt/dev/shell/ShellJavaScriptHost.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.UnableToCompleteException;
@@ -9,8 +23,8 @@
* method called setHost() that must be called when a new application is
* initialized.
*
- * This interface works with JavaScriptHost to keep running applications at
- * arms-length via an isolated class loader (this requires that there be no
+ * This interface works with JavaScriptHost to keep running applications at
+ * arms-length via an isolated class loader (this requires that there be no
* explicit dependencies between the shell and any client-side classes).
*/
public interface ShellJavaScriptHost {
@@ -33,6 +47,11 @@
abstract void ditchHandle(int opaque);
/**
+ * Call this when a JavaScript exception is caught.
+ */
+ abstract void exceptionCaught(int number, String name, String description);
+
+ /**
* Invoke a native JavaScript function that returns a boolean value.
*/
abstract boolean invokeNativeBoolean(String name, Object jthis,
@@ -105,18 +124,13 @@
Object[] args);
/**
+ * Logs to the dev shell logger.
+ */
+ abstract void log(String message, Throwable e);
+
+ /**
* Resolves a deferred binding request and create the requested object.
*/
abstract Object rebindAndCreate(String requestedTypeName)
throws UnableToCompleteException;
-
- /**
- * Call this when a JavaScript exception is caught.
- */
- abstract void exceptionCaught(int number, String name, String description);
-
- /**
- * Logs to the dev shell logger.
- */
- abstract void log(String message, Throwable e);
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/ShellMainWindow.java b/dev/core/src/com/google/gwt/dev/shell/ShellMainWindow.java
index 591f909..a2ff5c8 100644
--- a/dev/core/src/com/google/gwt/dev/shell/ShellMainWindow.java
+++ b/dev/core/src/com/google/gwt/dev/shell/ShellMainWindow.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
@@ -24,18 +38,25 @@
import org.eclipse.swt.widgets.ToolItem;
/**
- * Implements the GWTShell's main window control.
+ * Implements the GWTShell's main window control.
*/
public class ShellMainWindow extends Composite implements DisposeListener,
ShellListener {
private class Toolbar extends HeaderBarBase {
+ private ToolItem about;
+
+ private ToolItem clearLog;
+ private ToolItem collapseAll;
+ private ToolItem expandAll;
+ private ToolItem newWindow;
+
public Toolbar(Composite parent) {
super(parent);
newWindow = newItem("new-window.gif", "&Hosted Browser",
- "Opens a new hosted mode browser window for debugging");
+ "Opens a new hosted mode browser window for debugging");
newWindow.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String startupUrl = serverWindow.normalizeURL("/");
@@ -44,7 +65,7 @@
bw.go(startupUrl);
} catch (UnableToCompleteException e) {
getLogger().log(TreeLogger.ERROR,
- "Unable to open a new hosted browser window", e);
+ "Unable to open a new hosted browser window", e);
}
}
});
@@ -52,7 +73,7 @@
newSeparator();
collapseAll = newItem("collapse.gif", "&Collapse All",
- "Collapses all log entries");
+ "Collapses all log entries");
collapseAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
logPane.collapseAll();
@@ -60,7 +81,7 @@
});
expandAll = newItem("expand.gif", "&Expand All",
- "Expands all log entries");
+ "Expands all log entries");
expandAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
logPane.expandAll();
@@ -68,7 +89,7 @@
});
clearLog = newItem("clear-log.gif", "Clear &Log",
- "Removes all log entries");
+ "Removes all log entries");
clearLog.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
logPane.removeAll();
@@ -84,8 +105,7 @@
if (aboutHtml != null) {
String serial = verify("TwysxNpVumPBvFyBoxzLy");
StringBuffer sb = new StringBuffer();
- sb
- .append("<div style='overflow:hidden;width:100%;white-space:nowrap;font-size:1px'><br/><br/><br/><br/><font style='background-color:gray;color:lightgrey'>");
+ sb.append("<div style='overflow:hidden;width:100%;white-space:nowrap;font-size:1px'><br/><br/><br/><br/><font style='background-color:gray;color:lightgrey'>");
for (int i = 0; i < 100; ++i) {
sb.append(serial);
}
@@ -94,30 +114,51 @@
int pos;
while ((pos = aboutHtml.indexOf("<hr/>")) >= 0) {
aboutHtml = aboutHtml.substring(0, pos) + serial
- + aboutHtml.substring(pos + 5);
+ + aboutHtml.substring(pos + 5);
}
while ((pos = aboutHtml.indexOf("<body>")) >= 0) {
aboutHtml = aboutHtml.substring(0, pos)
- + "<body oncontextmenu='return false'>"
- + aboutHtml.substring(pos + 6);
+ + "<body oncontextmenu='return false'>"
+ + aboutHtml.substring(pos + 6);
}
} else {
aboutHtml = "Could not locate 'about.html' in installation directory.";
}
BrowserDialog browserDialog = new BrowserDialog(getShell(),
- getLogger(), aboutHtml);
+ getLogger(), aboutHtml);
browserDialog.open(true);
}
});
}
-
- private ToolItem about;
- private ToolItem clearLog;
- private ToolItem collapseAll;
- private ToolItem expandAll;
- private ToolItem newWindow;
}
+ private static String verify(String hash) {
+ char[] in = hash.toCharArray();
+ char[] ou = new char[in.length];
+ for (int i = 0, c = 0; i < in.length; ++i) {
+ if (in[i] < 'a') {
+ c += in[i] - 'A';
+ } else {
+ c += in[i] - 'a' - 26;
+ }
+
+ if (c == 0) {
+ ou[i] = ' ';
+ } else {
+ ou[i] = (char) ('@' + c);
+ }
+ }
+ return String.valueOf(ou);
+ }
+
+ private Color colorWhite;
+
+ private TreeLoggerWidget logPane;
+
+ private GWTShell serverWindow;
+
+ private Toolbar toolbar;
+
public ShellMainWindow(GWTShell serverWindow, final Shell parent,
int serverPort, boolean checkForUpdates) {
super(parent, SWT.NONE);
@@ -131,7 +172,8 @@
setLayout(new FillLayout());
if (serverPort > 0) {
- parent.setText("Google Web Toolkit Development Shell / Port " + serverPort);
+ parent.setText("Google Web Toolkit Development Shell / Port "
+ + serverPort);
} else {
parent.setText("Google Web Toolkit Development Shell");
}
@@ -168,8 +210,7 @@
// check for updates
if (checkForUpdates) {
try {
- final CheckForUpdates updateChecker = PlatformSpecific
- .createUpdateChecker();
+ final CheckForUpdates updateChecker = PlatformSpecific.createUpdateChecker();
if (updateChecker != null) {
final CheckForUpdates.UpdateAvailableCallback callback = new CheckForUpdates.UpdateAvailableCallback() {
public void onUpdateAvailable(final String html) {
@@ -213,10 +254,10 @@
boolean closeWindows = true;
if (System.getProperty("gwt.shell.endquick") == null) {
closeWindows = DialogBase.confirmAction((Shell) e.widget,
- "Closing the development shell will close " +
- "all hosted mode browsers. Continue?", "Confirm close");
- }
-
+ "Closing the development shell will close "
+ + "all hosted mode browsers. Continue?", "Confirm close");
+ }
+
if (closeWindows) {
serverWindow.closeAllBrowserWindows();
e.doit = true;
@@ -238,28 +279,4 @@
public void widgetDisposed(DisposeEvent e) {
colorWhite.dispose();
}
-
- private static String verify(String hash) {
- char[] in = hash.toCharArray();
- char[] ou = new char[in.length];
- for (int i = 0, c = 0; i < in.length; ++i) {
- if (in[i] < 'a') {
- c += in[i] - 'A';
- } else {
- c += in[i] - 'a' - 26;
- }
-
- if (c == 0) {
- ou[i] = ' ';
- } else {
- ou[i] = (char) ('@' + c);
- }
- }
- return String.valueOf(ou);
- }
-
- private Color colorWhite;
- private TreeLoggerWidget logPane;
- private GWTShell serverWindow;
- private Toolbar toolbar;
}
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 3d6660d..ef02b08 100644
--- a/dev/core/src/com/google/gwt/dev/shell/ShellModuleSpaceHost.java
+++ b/dev/core/src/com/google/gwt/dev/shell/ShellModuleSpaceHost.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.TreeLogger;
@@ -23,6 +37,20 @@
private static Map byteCodeCompilersByModule = new HashMap();
+ protected final File genDir;
+
+ protected final TypeOracle typeOracle;
+
+ private CompilingClassLoader classLoader;
+
+ private final TreeLogger logger;
+
+ private final ModuleDef module;
+
+ private RebindOracle rebindOracle;
+
+ private ModuleSpace space;
+
/**
* @param module the module associated with the hosted module space
*/
@@ -48,14 +76,15 @@
return logger;
}
- public void onModuleReady(ModuleSpace readySpace) throws UnableToCompleteException {
+ public void onModuleReady(ModuleSpace readySpace)
+ throws UnableToCompleteException {
this.space = readySpace;
// 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, module.getName());
+ SourceOracle srcOracle = new HostedModeSourceOracle(typeOracle,
+ module.getName());
// Create or find the compiler to be used by the compiling class loader.
//
@@ -63,16 +92,15 @@
// Establish an environment for JavaScript property providers to run.
//
- ModuleSpacePropertyOracle propOracle =
- new ModuleSpacePropertyOracle(module.getProperties(), readySpace);
+ ModuleSpacePropertyOracle propOracle = new ModuleSpacePropertyOracle(
+ module.getProperties(), readySpace);
// Set up the rebind oracle for the module.
// It has to wait until now because we need to inject javascript.
//
Rules rules = module.getRules();
- rebindOracle =
- new StandardRebindOracle(typeOracle, propOracle, rules, genDir,
- module.getCacheManager());
+ rebindOracle = new StandardRebindOracle(typeOracle, propOracle, rules,
+ genDir, module.getCacheManager());
// Create a completely isolated class loader which owns all classes
// associated with a particular module. This effectively builds a
@@ -113,12 +141,4 @@
throw new IllegalStateException("Module initialization error");
}
}
-
- protected final File genDir;
- protected final TypeOracle typeOracle;
- private CompilingClassLoader classLoader;
- private final TreeLogger logger;
- private final ModuleDef module;
- private RebindOracle rebindOracle;
- private ModuleSpace space;
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java b/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java
index 2d782ec..b7c86c7 100644
--- a/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java
+++ b/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.GeneratorContext;
@@ -47,6 +61,12 @@
public static class GeneratedCompilationUnitProvider extends
StaticCompilationUnitProvider {
+ public CharArrayWriter caw;
+
+ public PrintWriter pw;
+
+ public char[] source;
+
public GeneratedCompilationUnitProvider(String packageName,
String simpleTypeName) {
super(packageName, simpleTypeName, null);
@@ -71,10 +91,6 @@
}
return source;
}
-
- public CharArrayWriter caw;
- public PrintWriter pw;
- public char[] source;
}
private static final class GeneratedCUP extends URLCompilationUnitProvider {
@@ -89,6 +105,20 @@
}
}
+ private final CacheManager cacheManager;
+
+ private final Set committedGeneratedCups = new HashSet();
+
+ private final File genDir;
+
+ private final Set generatedTypeNames = new HashSet();
+
+ private final PropertyOracle propOracle;
+
+ private final TypeOracle typeOracle;
+
+ private final Map uncommittedGeneratedCupsByPrintWriter = new IdentityHashMap();
+
/**
* Normally, the compiler host would be aware of the same types that are
* available in the supplied type oracle although it isn't strictly required.
@@ -105,16 +135,14 @@
* Commits a pending generated type.
*/
public final void commit(TreeLogger logger, PrintWriter pw) {
- GeneratedCompilationUnitProvider gcup =
- (GeneratedCompilationUnitProvider) uncommittedGeneratedCupsByPrintWriter
- .get(pw);
+ GeneratedCompilationUnitProvider gcup = (GeneratedCompilationUnitProvider) uncommittedGeneratedCupsByPrintWriter.get(pw);
if (gcup != null) {
gcup.commit();
uncommittedGeneratedCupsByPrintWriter.remove(pw);
committedGeneratedCups.add(gcup);
} else {
logger.log(TreeLogger.WARN,
- "Generator attempted to commit an unknown stream", null);
+ "Generator attempted to commit an unknown stream", null);
}
}
@@ -140,16 +168,14 @@
TreeLogger subBranch = null;
if (branch.isLoggable(TreeLogger.DEBUG)) {
- subBranch =
- branch
- .branch(TreeLogger.DEBUG, "Generated source files...", null);
+ subBranch = branch.branch(TreeLogger.DEBUG,
+ "Generated source files...", null);
}
assert (cacheManager.getTypeOracle() == typeOracle);
TypeOracleBuilder builder = new TypeOracleBuilder(cacheManager);
for (Iterator iter = committedGeneratedCups.iterator(); iter.hasNext();) {
- GeneratedCompilationUnitProvider gcup =
- (GeneratedCompilationUnitProvider) iter.next();
+ GeneratedCompilationUnitProvider gcup = (GeneratedCompilationUnitProvider) iter.next();
String typeName = gcup.getTypeName();
String genTypeName = gcup.getPackageName() + "." + typeName;
genTypeNames.add(genTypeName);
@@ -184,15 +210,11 @@
// Remind the user if there uncommitted cups.
//
if (!uncommittedGeneratedCupsByPrintWriter.isEmpty()) {
- String msg =
- "For the following type(s), generated source was never committed (did you forget to call commit()?)";
+ String msg = "For the following type(s), generated source was never committed (did you forget to call commit()?)";
logger = logger.branch(TreeLogger.WARN, msg, null);
- for (Iterator iter =
- uncommittedGeneratedCupsByPrintWriter.values().iterator(); iter
- .hasNext();) {
- StaticCompilationUnitProvider cup =
- (StaticCompilationUnitProvider) iter.next();
+ for (Iterator iter = uncommittedGeneratedCupsByPrintWriter.values().iterator(); iter.hasNext();) {
+ StaticCompilationUnitProvider cup = (StaticCompilationUnitProvider) iter.next();
String typeName = cup.getPackageName() + "." + cup.getTypeName();
logger.log(TreeLogger.WARN, typeName, null);
}
@@ -221,17 +243,16 @@
JClassType existingType = typeOracle.findType(packageName, simpleTypeName);
if (existingType != null) {
logger.log(TreeLogger.DEBUG, "Type '" + typeName
- + "' already exists and will not be re-created ", null);
+ + "' already exists and will not be re-created ", null);
return null;
}
// Has anybody tried to create this type during this iteraion?
//
if (generatedTypeNames.contains(typeName)) {
- final String msg =
- "A request to create type '"
- + typeName
- + "' was received while the type itself was being created; this might be a generator or configuration bug";
+ final String msg = "A request to create type '"
+ + typeName
+ + "' was received while the type itself was being created; this might be a generator or configuration bug";
logger.log(TreeLogger.WARN, msg, null);
return null;
}
@@ -239,8 +260,8 @@
// The type isn't there, so we can let the caller create it. Remember that
// it is pending so another attempt to create the same type will fail.
//
- GeneratedCompilationUnitProvider gcup =
- new GeneratedCompilationUnitProvider(packageName, simpleTypeName);
+ GeneratedCompilationUnitProvider gcup = new GeneratedCompilationUnitProvider(
+ packageName, simpleTypeName);
uncommittedGeneratedCupsByPrintWriter.put(gcup.pw, gcup);
generatedTypeNames.add(typeName);
@@ -281,24 +302,15 @@
Throwable caught = null;
try {
URL fileURL = srcFile.toURL();
- URLCompilationUnitProvider fileBaseCup =
- new GeneratedCUP(fileURL, cup.getPackageName());
+ URLCompilationUnitProvider fileBaseCup = new GeneratedCUP(fileURL,
+ cup.getPackageName());
return fileBaseCup;
} catch (MalformedURLException e) {
caught = e;
}
logger.log(TreeLogger.ERROR,
- "Internal error: cannot build URL from synthesized file name '"
- + srcFile.getAbsolutePath() + "'", caught);
+ "Internal error: cannot build URL from synthesized file name '"
+ + srcFile.getAbsolutePath() + "'", caught);
throw new UnableToCompleteException();
}
-
- private final CacheManager cacheManager;
- private final Set committedGeneratedCups = new HashSet();
- private final File genDir;
- private final Set generatedTypeNames = new HashSet();
- private final PropertyOracle propOracle;
- private final TypeOracle typeOracle;
- private final Map uncommittedGeneratedCupsByPrintWriter =
- new IdentityHashMap();
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/StandardRebindOracle.java b/dev/core/src/com/google/gwt/dev/shell/StandardRebindOracle.java
index 22078a3..e00406e 100644
--- a/dev/core/src/com/google/gwt/dev/shell/StandardRebindOracle.java
+++ b/dev/core/src/com/google/gwt/dev/shell/StandardRebindOracle.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 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
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.dev.shell;
import com.google.gwt.core.ext.PropertyOracle;
@@ -31,9 +45,15 @@
*/
private final class Rebinder {
+ private final StandardGeneratorContext genCtx;
+
+ private final Set usedRules = new HashSet();
+
+ private final List usedTypeNames = new ArrayList();
+
public Rebinder(TypeOracle typeOracle, PropertyOracle propOracle) {
genCtx = new StandardGeneratorContext(typeOracle, propOracle, genDir,
- cacheManager);
+ cacheManager);
}
public String rebind(TreeLogger logger, String typeName)
@@ -59,10 +79,8 @@
if (usedTypeNames.contains(typeName)) {
// Found a cycle.
//
- String[] cycle = (String[]) Util
- .toArray(String.class, usedTypeNames);
- Messages.UNABLE_TO_REBIND_DUE_TO_CYCLE_IN_RULES
- .log(logger, cycle, null);
+ String[] cycle = (String[]) Util.toArray(String.class, usedTypeNames);
+ Messages.UNABLE_TO_REBIND_DUE_TO_CYCLE_IN_RULES.log(logger, cycle, null);
throw new UnableToCompleteException();
}
@@ -74,7 +92,7 @@
//
if (rules.isEmpty()) {
logger.log(TreeLogger.DEBUG,
- "No rules are defined, so no substitution can occur", null);
+ "No rules are defined, so no substitution can occur", null);
return null;
}
@@ -84,7 +102,7 @@
// Branch the logger.
//
TreeLogger branch = Messages.TRACE_CHECKING_RULE.branch(logger, rule,
- null);
+ null);
if (rule.isApplicable(branch, genCtx, typeName)) {
// See if this rule has already been used. This is needed to prevent
@@ -112,11 +130,18 @@
//
return null;
}
-
- private final StandardGeneratorContext genCtx;
- private final Set usedRules = new HashSet();
- private final List usedTypeNames = new ArrayList();
}
+
+ private final CacheManager cacheManager;
+
+ private final File genDir;
+
+ private final PropertyOracle propOracle;
+
+ private final Rules rules;
+
+ private final TypeOracle typeOracle;
+
public StandardRebindOracle(TypeOracle typeOracle, PropertyOracle propOracle,
Rules rules, File genDir, CacheManager cacheManager) {
this.typeOracle = typeOracle;
@@ -130,7 +155,8 @@
}
}
- public StandardRebindOracle(TypeOracle typeOracle, StaticPropertyOracle propOracle, Rules rules, File genDir) {
+ public StandardRebindOracle(TypeOracle typeOracle,
+ StaticPropertyOracle propOracle, Rules rules, File genDir) {
// This is a path used for non-hosted mode execution; therefore no caching.
this(typeOracle, propOracle, rules, genDir, null);
}
@@ -166,10 +192,4 @@
return false;
}
- private final CacheManager cacheManager;
- private final File genDir;
- private final PropertyOracle propOracle;
- private final Rules rules;
- private final TypeOracle typeOracle;
-
}