A small round of doc and error message fixes. 
- JsValueGlue.java and ModuleSpace.java now report message more clearly when there is a mismatch between the declared return type and the actual JS result type.
- Added the new DOM client package to the javadoc build, including a new package.html file.
- Removed the comment in JavaScriptObject.java saying that JSO can't be subclassed.

Patch by: bruce
Review by: rdayal (desk check)

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2415 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java b/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
index 611f95d..21d9b7e 100644
--- a/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
+++ b/dev/core/src/com/google/gwt/dev/shell/JsValueGlue.java
@@ -49,7 +49,7 @@
     if (value.isUndefined()) {
       // undefined is never legal to return from JavaScript into Java
       throw new HostedModeException(msgPrefix
-          + ": JavaScript undefined, expected " + type.getName());
+          + ": attempt to use JavaScript 'undefined' as a value, expected " + type.getName());
     }
 
     if (type.isPrimitive()) {
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 e11d268..c43267c 100644
--- a/dev/core/src/com/google/gwt/dev/shell/ModuleSpace.java
+++ b/dev/core/src/com/google/gwt/dev/shell/ModuleSpace.java
@@ -164,11 +164,11 @@
   public String getModuleName() {
     return moduleName;
   }
-
+  
   public boolean invokeNativeBoolean(String name, Object jthis,
       Class<?>[] types, Object[] args) throws Throwable {
     JsValue result = invokeNative(name, jthis, types, args);
-    String msgPrefix = "invokeNativeBoolean(" + name + ")";
+    String msgPrefix = composeResultErrorMsgPrefix(name, "a boolean");
     Boolean value = JsValueGlue.get(result, getIsolatedClassLoader(),
         boolean.class, msgPrefix);
     if (value == null) {
@@ -181,7 +181,7 @@
   public byte invokeNativeByte(String name, Object jthis, Class<?>[] types,
       Object[] args) throws Throwable {
     JsValue result = invokeNative(name, jthis, types, args);
-    String msgPrefix = "invokeNativeByte(" + name + ")";
+    String msgPrefix = composeResultErrorMsgPrefix(name, "a byte");
     Byte value = JsValueGlue.get(result, null, Byte.TYPE, msgPrefix);
     if (value == null) {
       throw new HostedModeException(msgPrefix
@@ -193,7 +193,7 @@
   public char invokeNativeChar(String name, Object jthis, Class<?>[] types,
       Object[] args) throws Throwable {
     JsValue result = invokeNative(name, jthis, types, args);
-    String msgPrefix = "invokeNativeCharacter(" + name + ")";
+    String msgPrefix = composeResultErrorMsgPrefix(name, "a char");
     Character value = JsValueGlue.get(result, null, Character.TYPE, msgPrefix);
     if (value == null) {
       throw new HostedModeException(msgPrefix
@@ -205,7 +205,7 @@
   public double invokeNativeDouble(String name, Object jthis, Class<?>[] types,
       Object[] args) throws Throwable {
     JsValue result = invokeNative(name, jthis, types, args);
-    String msgPrefix = "invokeNativeDouble(" + name + ")";
+    String msgPrefix = composeResultErrorMsgPrefix(name, "a double");
     Double value = JsValueGlue.get(result, null, Double.TYPE, msgPrefix);
     if (value == null) {
       throw new HostedModeException(msgPrefix
@@ -217,7 +217,7 @@
   public float invokeNativeFloat(String name, Object jthis, Class<?>[] types,
       Object[] args) throws Throwable {
     JsValue result = invokeNative(name, jthis, types, args);
-    String msgPrefix = "invokeNativeFloat(" + name + ")";
+    String msgPrefix = composeResultErrorMsgPrefix(name, "a float");
     Float value = JsValueGlue.get(result, null, Float.TYPE, msgPrefix);
     if (value == null) {
       throw new HostedModeException(msgPrefix
@@ -229,7 +229,7 @@
   public int invokeNativeInt(String name, Object jthis, Class<?>[] types,
       Object[] args) throws Throwable {
     JsValue result = invokeNative(name, jthis, types, args);
-    String msgPrefix = "invokeNativeInteger(" + name + ")";
+    String msgPrefix = composeResultErrorMsgPrefix(name, "an int");
     Integer value = JsValueGlue.get(result, null, Integer.TYPE, msgPrefix);
     if (value == null) {
       throw new HostedModeException(msgPrefix
@@ -241,7 +241,7 @@
   public long invokeNativeLong(String name, Object jthis, Class<?>[] types,
       Object[] args) throws Throwable {
     JsValue result = invokeNative(name, jthis, types, args);
-    String msgPrefix = "invokeNativeLong(" + name + ")";
+    String msgPrefix = composeResultErrorMsgPrefix(name, "a long");
     Long value = JsValueGlue.get(result, null, Long.TYPE, msgPrefix);
     if (value == null) {
       throw new HostedModeException(msgPrefix
@@ -253,14 +253,15 @@
   public Object invokeNativeObject(String name, Object jthis, Class<?>[] types,
       Object[] args) throws Throwable {
     JsValue result = invokeNative(name, jthis, types, args);
+    String msgPrefix = composeResultErrorMsgPrefix(name, "a Java object");
     return JsValueGlue.get(result, getIsolatedClassLoader(), Object.class,
-        "invokeNativeObject(" + name + ")");
+        msgPrefix);
   }
 
   public short invokeNativeShort(String name, Object jthis, Class<?>[] types,
       Object[] args) throws Throwable {
     JsValue result = invokeNative(name, jthis, types, args);
-    String msgPrefix = "invokeNativeShort(" + name + ")";
+    String msgPrefix = composeResultErrorMsgPrefix(name, "a short");
     Short value = JsValueGlue.get(result, null, Short.TYPE, msgPrefix);
     if (value == null) {
       throw new HostedModeException(msgPrefix
@@ -276,7 +277,7 @@
       getLogger().log(
           TreeLogger.WARN,
           "JSNI method '" + name + "' returned a value of type "
-              + result.getTypeString() + "; should not have returned a value",
+              + result.getTypeString() + " but was declared void; it should not have returned a value at all",
           null);
     }
   }
@@ -517,6 +518,10 @@
     setJavaScriptHost(null, getIsolatedClassLoader());
   }
 
+  private String composeResultErrorMsgPrefix(String name, String typePhrase) {
+    return "Something other than " + typePhrase + " was returned from JSNI method '" + name + "'";
+  }
+
   /**
    * Handles loading a class that might be nested given a source type name.
    */
diff --git a/distro-source/core/src/doc/helpInfo/longJsniRestriction.html b/distro-source/core/src/doc/helpInfo/longJsniRestriction.html
index 0c881b1..cbbb033 100644
--- a/distro-source/core/src/doc/helpInfo/longJsniRestriction.html
+++ b/distro-source/core/src/doc/helpInfo/longJsniRestriction.html
@@ -26,8 +26,8 @@
     <code>long</code> emulation.
 
     <li> For values meant to be passed through unchanged to Java code,
-    wrap the value in a <code>long</code>.  There are no restrictions
-    on type <code>long</code> with JSNI methods.
+    wrap the value in a <code>Long</code>.  There are no restrictions
+    on type <code>Long</code> with JSNI methods.
 
     <li> If you are sure you know what you are doing, you can add the
     annotation
diff --git a/doc/build.xml b/doc/build.xml
index b544db7..fcd858c 100644
--- a/doc/build.xml
+++ b/doc/build.xml
@@ -10,7 +10,7 @@
 	<property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev-linux.jar" />
 
 	<property name="USER_PKGS"
-          value="com.google.gwt.core.client;com.google.gwt.core.ext;com.google.gwt.core.ext.linker;com.google.gwt.core.ext.typeinfo;com.google.gwt.i18n.client;com.google.gwt.i18n.rebind.format;com.google.gwt.i18n.rebind.keygen;com.google.gwt.json.client;com.google.gwt.junit.client;com.google.gwt.user.client;com.google.gwt.user.client.rpc;com.google.gwt.user.client.ui;com.google.gwt.user.server.rpc;com.google.gwt.xml.client;com.google.gwt.http.client;com.google.gwt.junit.viewer.client" />
+          value="com.google.gwt.core.client;com.google.gwt.core.ext;com.google.gwt.core.ext.linker;com.google.gwt.core.ext.typeinfo;com.google.gwt.dom.client;com.google.gwt.i18n.client;com.google.gwt.i18n.rebind.format;com.google.gwt.i18n.rebind.keygen;com.google.gwt.json.client;com.google.gwt.junit.client;com.google.gwt.user.client;com.google.gwt.user.client.rpc;com.google.gwt.user.client.ui;com.google.gwt.user.server.rpc;com.google.gwt.xml.client;com.google.gwt.http.client;com.google.gwt.junit.viewer.client" />
 	<property name="LANG_PKGS" value="java.lang;java.lang.annotation;java.util;java.io" />
 
 	<!--
diff --git a/user/src/com/google/gwt/core/client/JavaScriptObject.java b/user/src/com/google/gwt/core/client/JavaScriptObject.java
index 2fd1f7f..03f426c 100644
--- a/user/src/com/google/gwt/core/client/JavaScriptObject.java
+++ b/user/src/com/google/gwt/core/client/JavaScriptObject.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -24,10 +24,6 @@
  * JSNI method that returns native (non-Java) objects. A
  * <code>JavaScriptObject</code> passed back into JSNI from Java becomes the
  * original object, and can be accessed in JavaScript as expected.
- * 
- * <p>
- * <b>SUBCLASSING IS NOT SUPPORTED EXCEPT FOR THE EXISTING SUBCLASSES.</b>
- * </p>
  */
 public class JavaScriptObject {
 
diff --git a/user/src/com/google/gwt/dom/client/package.html b/user/src/com/google/gwt/dom/client/package.html
new file mode 100644
index 0000000..b112683
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/package.html
@@ -0,0 +1,18 @@
+<html>
+<body>
+Classes for low-level DOM programming.
+
+This package contains classes that expose the W3C standard HTML document object model for programmatic access 
+and manipulation of HTML pages directly in client-side Java source, accounting for most browser variations.
+These classes provide an efficient, type-safe, and IDE-friendly alternative to writing 
+JavaScript Native Interface (JSNI) methods for many common tasks.
+
+<p>
+These classes extend {@link com.google.gwt.core.client.JavaScriptObject}, which enables them to be
+used directly as Java types without introducing any object-oriented size or speed overhead beyond the 
+underlying JavaScript objects they represent. 
+Consequently, these DOM classes are efficient enough to be used directly when maximum performance is required 
+and are lightweight enough to serve as the basic building blocks upon which widget libraries may be constructed.
+</p>
+</body>
+</html>