| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Google Web Toolkit
Revision: 3591
Author: scottb@google.com
Date: 28 Aug 2008 18:56:54
Changes:Merging releases/1.5 into trunk
svn merge -r3550:3556 https://google-web-toolkit.googlecode.com/svn/releases/1.5 .
Files:| ... | ...@@ -17,7 +17,7 @@ | |
| 17 | 17 | function gwtOnLoad(errFn, modName, modBase){ |
| 18 | 18 | $moduleName = modName; |
| 19 | 19 | $moduleBase = modBase; |
| 20 | if (!external.gwtOnLoad(window, modName)) { | |
| 20 | if (!external.gwtOnLoad(window, modName, "1.5")) { | |
| 21 | 21 | if (errFn) { |
| 22 | 22 | errFn(modName); |
| 23 | 23 | } |
| ... | ...@@ -29,7 +29,7 @@ | |
| 29 | 29 | }; |
| 30 | 30 | |
| 31 | 31 | window.onunload = function() { |
| 32 | external.gwtOnLoad(window, null); | |
| 32 | external.gwtOnLoad(window, null, "1.5"); | |
| 33 | 33 | }; |
| 34 | 34 | |
| 35 | 35 | window.__gwt_module_id = 0; |
| ... | ...@@ -1,5 +1,5 @@ | |
| 1 | 1 | /* |
| 2 | * Copyright 2007 Google Inc. | |
| 2 | * Copyright 2008 Google Inc. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | 5 | * use this file except in compliance with the License. You may obtain a copy of |
| ... | ...@@ -41,7 +41,7 @@ | |
| 41 | 41 | void method1(); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | private final String VALID_ENCODED_REQUEST = "3\uffff" + // version | |
| 44 | private static final String VALID_ENCODED_REQUEST = "4\uffff" + // version | |
| 45 | 45 | "0\uffff" + // flags |
| 46 | 46 | "4\uffff" + // string table entry count |
| 47 | 47 | A.class.getName() + "\uffff" + // string table entry #0 |
| ... | ...@@ -54,7 +54,7 @@ | |
| 54 | 54 | "2\uffff" + // method name |
| 55 | 55 | "0\uffff"; // param count |
| 56 | 56 | |
| 57 | private final String INVALID_METHOD_REQUEST = "3\uffff" + // version | |
| 57 | private static final String INVALID_METHOD_REQUEST = "4\uffff" + // version | |
| 58 | 58 | "0\uffff" + // flags |
| 59 | 59 | "4\uffff" + // string table entry count |
| 60 | 60 | A.class.getName() + "\uffff" + // string table entry #0 |
| ... | ...@@ -67,7 +67,7 @@ | |
| 67 | 67 | "2\uffff" + // method name |
| 68 | 68 | "0\uffff"; // param count |
| 69 | 69 | |
| 70 | private final String INVALID_INTERFACE_REQUEST = "3\uffff" + // version | |
| 70 | private static final String INVALID_INTERFACE_REQUEST = "4\uffff" + // version | |
| 71 | 71 | "0\uffff" + // flags |
| 72 | 72 | "4\uffff" + // string table entry count |
| 73 | 73 | B.class.getName() + "\uffff" + // string table entry #0 |
| ... | ...@@ -80,7 +80,7 @@ | |
| 80 | 80 | "2\uffff" + // method name |
| 81 | 81 | "0\uffff"; // param count |
| 82 | 82 | |
| 83 | private final String VALID_PRE_RPC_RESOURCE_ENCODED_REQUEST = "2\uffff" + // version | |
| 83 | private static final String VALID_V2_ENCODED_REQUEST = "2\uffff" + // version | |
| 84 | 84 | "0\uffff" + // flags |
| 85 | 85 | "2\uffff" + // string table entry count |
| 86 | 86 | A.class.getName() + "\uffff" + // string table entry #0 |
| ... | ...@@ -89,6 +89,39 @@ | |
| 89 | 89 | "2\uffff" + // method name |
| 90 | 90 | "0\uffff"; // param count |
| 91 | 91 | |
| 92 | private static final String VALID_V3_ENCODED_REQUEST = "3\uffff" + // version | |
| 93 | "0\uffff" + // flags | |
| 94 | "4\uffff" + // string table entry count | |
| 95 | A.class.getName() + "\uffff" + // string table entry #0 | |
| 96 | "method2" + "\uffff" + // string table entry #1 | |
| 97 | "moduleBaseURL" + "\uffff" + // string table entry #2 | |
| 98 | "whitelistHashcode" + "\uffff" + // string table entry #4 | |
| 99 | "3\uffff" + // module base URL | |
| 100 | "4\uffff" + // whitelist hashcode | |
| 101 | "1\uffff" + // interface name | |
| 102 | "2\uffff" + // method name | |
| 103 | "0\uffff"; // param count | |
| 104 | ||
| 105 | /** | |
| 106 | * Tests that seeing obsolete RPC formats throws an | |
| 107 | * {@link IncompatibleRemoteServiceException}. | |
| 108 | */ | |
| 109 | public void testDecodeObsoleteFormats() { | |
| 110 | try { | |
| 111 | RPC.decodeRequest(VALID_V2_ENCODED_REQUEST, A.class, null); | |
| 112 | fail("Should have thrown an IncompatibleRemoteServiceException"); | |
| 113 | } catch (IncompatibleRemoteServiceException e) { | |
| 114 | // Expected | |
| 115 | } | |
| 116 | ||
| 117 | try { | |
| 118 | RPC.decodeRequest(VALID_V3_ENCODED_REQUEST, A.class, null); | |
| 119 | fail("Should have thrown an IncompatibleRemoteServiceException"); | |
| 120 | } catch (IncompatibleRemoteServiceException e) { | |
| 121 | // Expected | |
| 122 | } | |
| 123 | } | |
| 124 | ||
| 92 | 125 | /** |
| 93 | 126 | * Tests for method {@link RPC#decodeRequest(String)} |
| 94 | 127 | * |
| ... | ...@@ -184,20 +217,6 @@ | |
| 184 | 217 | } |
| 185 | 218 | |
| 186 | 219 | /** |
| 187 | * Tests that method | |
| 188 | * {@link RPC#decodeRequest(String, Class, SerializationPolicyProvider)} can | |
| 189 | * handle the decoding of requests from pre-RPC resource (whitelist) clients. | |
| 190 | * | |
| 191 | * @throws SerializationException | |
| 192 | */ | |
| 193 | public void testDecodeRequestPreRPCResourceFile() { | |
| 194 | RPCRequest rpcRequest = RPC.decodeRequest( | |
| 195 | VALID_PRE_RPC_RESOURCE_ENCODED_REQUEST, A.class, null); | |
| 196 | SerializationPolicy serializationPolicy = rpcRequest.getSerializationPolicy(); | |
| 197 | assertEquals(RPC.getDefaultSerializationPolicy(), serializationPolicy); | |
| 198 | } | |
| 199 | ||
| 200 | /** | |
| 201 | 220 | * Tests for method {@link RPC#encodeResponseForFailure(Method, Throwable)}. |
| 202 | 221 | * |
| 203 | 222 | * Cases: |
| ... | ...@@ -568,11 +568,7 @@ | |
| 568 | 568 | assert (instance != null); |
| 569 | 569 | |
| 570 | 570 | Class<?> clazz = getClassForSerialization(instance); |
| 571 | if (shouldEnforceTypeVersioning()) { | |
| 572 | return SerializabilityUtil.encodeSerializedInstanceReference(clazz); | |
| 573 | } else { | |
| 574 | return SerializabilityUtil.getSerializedTypeName(clazz); | |
| 575 | } | |
| 571 | return SerializabilityUtil.encodeSerializedInstanceReference(clazz); | |
| 576 | 572 | } |
| 577 | 573 | |
| 578 | 574 | @Override |
| ... | ...@@ -18,6 +18,7 @@ | |
| 18 | 18 | import com.google.gwt.core.client.GWT; |
| 19 | 19 | import com.google.gwt.core.client.JavaScriptObject; |
| 20 | 20 | import com.google.gwt.core.client.UnsafeNativeLong; |
| 21 | import com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException; | |
| 21 | 22 | import com.google.gwt.user.client.rpc.SerializationException; |
| 22 | 23 | |
| 23 | 24 | /** |
| ... | ...@@ -56,6 +57,13 @@ | |
| 56 | 57 | results = eval(encoded); |
| 57 | 58 | index = getLength(results); |
| 58 | 59 | super.prepareToRead(encoded); |
| 60 | ||
| 61 | if (getVersion() != SERIALIZATION_STREAM_VERSION) { | |
| 62 | throw new IncompatibleRemoteServiceException("Expecting version " | |
| 63 | + SERIALIZATION_STREAM_VERSION + " from server, got " + getVersion() | |
| 64 | + "."); | |
| 65 | } | |
| 66 | ||
| 59 | 67 | stringTable = readJavaScriptObject(); |
| 60 | 68 | } |
| 61 | 69 |
| ... | ...@@ -1,5 +1,5 @@ | |
| 1 | 1 | /* |
| 2 | * Copyright 2007 Google Inc. | |
| 2 | * Copyright 2008 Google Inc. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | 5 | * use this file except in compliance with the License. You may obtain a copy of |
| ... | ...@@ -22,17 +22,12 @@ | |
| 22 | 22 | */ |
| 23 | 23 | public abstract class AbstractSerializationStream { |
| 24 | 24 | |
| 25 | public static final int SERIALIZATION_STREAM_FLAGS_NO_TYPE_VERSIONING = 1; | |
| 26 | public static final int SERIALIZATION_STREAM_VERSION = 3; | |
| 27 | ||
| 28 | 25 | /** |
| 29 | * The last legacy stream version which does not use a | |
| 30 | * {@link com.google.gwt.user.server.rpc.SerializationPolicy SerializationPolicy}. | |
| 26 | * This is the only supported RPC protocol version. | |
| 31 | 27 | */ |
| 32 | public static final int SERIALIZATION_STREAM_VERSION_WITHOUT_SERIALIZATION_POLICY = 2; | |
| 28 | public static final int SERIALIZATION_STREAM_VERSION = 4; | |
| 33 | 29 | |
| 34 | 30 | private int flags = 0; |
| 35 | ||
| 36 | 31 | private int version = SERIALIZATION_STREAM_VERSION; |
| 37 | 32 | |
| 38 | 33 | public final void addFlags(int flags) { |
| ... | ...@@ -51,21 +46,6 @@ | |
| 51 | 46 | this.flags = flags; |
| 52 | 47 | } |
| 53 | 48 | |
| 54 | public final boolean shouldEnforceTypeVersioning() { | |
| 55 | return (flags & SERIALIZATION_STREAM_FLAGS_NO_TYPE_VERSIONING) == 0; | |
| 56 | } | |
| 57 | ||
| 58 | /** | |
| 59 | * Returns <code>true</code> if this stream encodes information which can be | |
| 60 | * used to lookup a {@link com.google.gwt.user.server.rpc.SerializationPolicy}. | |
| 61 | * | |
| 62 | * @return <code>true</code> if this stream encodes information which can be | |
| 63 | * used to lookup a <code>SerializationPolicy</code> | |
| 64 | */ | |
| 65 | protected boolean hasSerializationPolicyInfo() { | |
| 66 | return getVersion() > SERIALIZATION_STREAM_VERSION_WITHOUT_SERIALIZATION_POLICY; | |
| 67 | } | |
| 68 | ||
| 69 | 49 | protected final void setVersion(int version) { |
| 70 | 50 | this.version = version; |
| 71 | 51 | } |
| ... | ...@@ -54,8 +54,6 @@ | |
| 54 | 54 | |
| 55 | 55 | private final GeneratorContext context; |
| 56 | 56 | |
| 57 | private final boolean enforceTypeVersioning; | |
| 58 | ||
| 59 | 57 | private final JType[] serializableTypes; |
| 60 | 58 | |
| 61 | 59 | private final SerializableTypeOracle serializationOracle; |
| ... | ...@@ -74,9 +72,6 @@ | |
| 74 | 72 | this.serializationOracle = serializationOracle; |
| 75 | 73 | this.typeOracle = context.getTypeOracle(); |
| 76 | 74 | |
| 77 | enforceTypeVersioning = Shared.shouldEnforceTypeVersioning(logger, | |
| 78 | context.getPropertyOracle()); | |
| 79 | ||
| 80 | 75 | serializableTypes = serializationOracle.getSerializableTypes(); |
| 81 | 76 | |
| 82 | 77 | srcWriter = getSourceWriter(logger, context); |
| ... | ...@@ -99,9 +94,7 @@ | |
| 99 | 94 | |
| 100 | 95 | writeCreateMethodMapMethod(); |
| 101 | 96 | |
| 102 | if (shouldEnforceTypeVersioning()) { | |
| 103 | writeCreateSignatureMapMethod(); | |
| 104 | } | |
| 97 | writeCreateSignatureMapMethod(); | |
| 105 | 98 | |
| 106 | 99 | writeRaiseSerializationException(); |
| 107 | 100 | |
| ... | ...@@ -246,10 +239,6 @@ | |
| 246 | 239 | return true; |
| 247 | 240 | } |
| 248 | 241 | |
| 249 | private boolean shouldEnforceTypeVersioning() { | |
| 250 | return enforceTypeVersioning; | |
| 251 | } | |
| 252 | ||
| 253 | 242 | private void writeCreateMethodMapMethod() { |
| 254 | 243 | srcWriter.println("@SuppressWarnings(\"restriction\")"); |
| 255 | 244 | srcWriter.println("private static native JavaScriptObject createMethodMap() /*-" + '{'); |
| ... | ...@@ -270,11 +259,8 @@ | |
| 270 | 259 | needComma = true; |
| 271 | 260 | } |
| 272 | 261 | |
| 273 | String typeString = serializationOracle.getSerializedTypeName(type); | |
| 274 | if (shouldEnforceTypeVersioning()) { | |
| 275 | typeString += "/" | |
| 276 | + serializationOracle.getSerializationSignature(type); | |
| 277 | } | |
| 262 | String typeString = serializationOracle.getSerializedTypeName(type) | |
| 263 | + "/" + serializationOracle.getSerializationSignature(type); | |
| 278 | 264 | |
| 279 | 265 | srcWriter.print("\"" + typeString + "\":"); |
| 280 | 266 | |
| ... | ...@@ -427,19 +413,13 @@ | |
| 427 | 413 | } |
| 428 | 414 | |
| 429 | 415 | private void writeGetSerializationSignatureMethod() { |
| 430 | if (!shouldEnforceTypeVersioning()) { | |
| 431 | srcWriter.println("public String getSerializationSignature(String typeName) {"); | |
| 432 | srcWriter.indentln("return null;"); | |
| 433 | srcWriter.println("};"); | |
| 434 | } else { | |
| 435 | String serializerTypeName = getTypeSerializerClassName(); | |
| 436 | srcWriter.println("public native String getSerializationSignature(String typeName) /*-" + '{'); | |
| 437 | srcWriter.indent(); | |
| 438 | srcWriter.println("return @" + serializerTypeName | |
| 439 | + "::signatureMap[typeName];"); | |
| 440 | srcWriter.outdent(); | |
| 441 | srcWriter.println("}-*/;"); | |
| 442 | } | |
| 416 | String serializerTypeName = getTypeSerializerClassName(); | |
| 417 | srcWriter.println("public native String getSerializationSignature(String typeName) /*-" + '{'); | |
| 418 | srcWriter.indent(); | |
| 419 | srcWriter.println("return @" + serializerTypeName | |
| 420 | + "::signatureMap[typeName];"); | |
| 421 | srcWriter.outdent(); | |
| 422 | srcWriter.println("}-*/;"); | |
| 443 | 423 | srcWriter.println(); |
| 444 | 424 | } |
| 445 | 425 | |
| ... | ...@@ -490,9 +470,7 @@ | |
| 490 | 470 | |
| 491 | 471 | private void writeStaticFields() { |
| 492 | 472 | srcWriter.println("private static final JavaScriptObject methodMap = createMethodMap();"); |
| 493 | if (shouldEnforceTypeVersioning()) { | |
| 494 | srcWriter.println("private static final JavaScriptObject signatureMap = createSignatureMap();"); | |
| 495 | } | |
| 473 | srcWriter.println("private static final JavaScriptObject signatureMap = createSignatureMap();"); | |
| 496 | 474 | srcWriter.println(); |
| 497 | 475 | } |
| 498 | 476 | } |
| 499 | 477 | \ No newline at end of file |
| ... | ...@@ -51,20 +51,23 @@ | |
| 51 | 51 | */ |
| 52 | 52 | public final class IncompatibleRemoteServiceException extends RuntimeException |
| 53 | 53 | implements IsSerializable { |
| 54 | ||
| 55 | private static final String DEFAULT_MESSAGE = "This application is out of " | |
| 56 | + "date, please click the refresh button on your browser."; | |
| 57 | ||
| 54 | 58 | /** |
| 55 | 59 | * Constructor used by RPC serialization. Note that the client side code will |
| 56 | 60 | * always get a generic error message. |
| 57 | 61 | */ |
| 58 | 62 | public IncompatibleRemoteServiceException() { |
| 59 | super( | |
| 60 | "This application is out of date, please click the refresh button on your browser"); | |
| 63 | super(DEFAULT_MESSAGE); | |
| 61 | 64 | } |
| 62 | 65 | |
| 63 | 66 | /** |
| 64 | 67 | * Constructs an instance with the specified message. |
| 65 | 68 | */ |
| 66 | 69 | public IncompatibleRemoteServiceException(String msg) { |
| 67 | super(msg); | |
| 70 | super(DEFAULT_MESSAGE + " ( " + msg + " )"); | |
| 68 | 71 | } |
| 69 | 72 | |
| 70 | 73 | /** |
| ... | ...@@ -68,6 +68,11 @@ | |
| 68 | 68 | moduleName = JS_ValueToString(cx, argv[1]); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | JSString* version = 0; | |
| 72 | if (argc > 2 && argv[2] != JSVAL_NULL && argv[2] != JSVAL_VOID) { | |
| 73 | version = JS_ValueToString(cx, argv[2]); | |
| 74 | } | |
| 75 | ||
| 71 | 76 | nsCOMPtr<nsIScriptGlobalObject> scriptGlobal(0); |
| 72 | 77 | if (scriptWindow) { |
| 73 | 78 | nsCOMPtr<nsIXPConnect> xpConnect = do_GetService(nsIXPConnect::GetCID()); |
| ... | ...@@ -93,6 +98,19 @@ | |
| 93 | 98 | tracer.log("null module name"); |
| 94 | 99 | } |
| 95 | 100 | |
| 101 | jstring jVersion(0); | |
| 102 | if (version) { | |
| 103 | jVersion = savedJNIEnv->NewString(JS_GetStringChars(version), | |
| 104 | JS_GetStringLength(version)); | |
| 105 | if (!jVersion || savedJNIEnv->ExceptionCheck()) { | |
| 106 | tracer.setFail("can't get module name in Java string"); | |
| 107 | return JS_FALSE; | |
| 108 | } | |
| 109 | tracer.log("version=%s", JS_GetStringBytes(version)); | |
| 110 | } else { | |
| 111 | tracer.log("null version"); | |
| 112 | } | |
| 113 | ||
| 96 | 114 | jobject externalObject = NS_REINTERPRET_CAST(jobject, JS_GetPrivate(cx, obj)); |
| 97 | 115 | jclass objClass = savedJNIEnv->GetObjectClass(externalObject); |
| 98 | 116 | if (!objClass || savedJNIEnv->ExceptionCheck()) { |
| ... | ...@@ -101,7 +119,7 @@ | |
| 101 | 119 | } |
| 102 | 120 | |
| 103 | 121 | jmethodID methodID = savedJNIEnv->GetMethodID(objClass, "gwtOnLoad", |
| 104 | "(ILjava/lang/String;)Z"); | |
| 122 | "(ILjava/lang/String;Ljava/lang/String;)Z"); | |
| 105 | 123 | if (!methodID || savedJNIEnv->ExceptionCheck()) { |
| 106 | 124 | tracer.setFail("can't get gwtOnLoad method"); |
| 107 | 125 | return JS_FALSE; |
| ... | ...@@ -110,7 +128,7 @@ | |
| 110 | 128 | tracer.log("scriptGlobal=%08x", unsigned(scriptGlobal.get())); |
| 111 | 129 | |
| 112 | 130 | jboolean result = savedJNIEnv->CallBooleanMethod(externalObject, methodID, |
| 113 | NS_REINTERPRET_CAST(jint, scriptGlobal.get()), jModuleName); | |
| 131 | NS_REINTERPRET_CAST(jint, scriptGlobal.get()), jModuleName, jVersion); | |
| 114 | 132 | if (savedJNIEnv->ExceptionCheck()) { |
| 115 | 133 | tracer.setFail("LowLevelMoz.ExternalObject.gwtOnLoad() threw an exception"); |
| 116 | 134 | return JS_FALSE; |
| ... | ...@@ -1,5 +1,5 @@ | |
| 1 | 1 | /* |
| 2 | * Copyright 2007 Google Inc. | |
| 2 | * Copyright 2008 Google Inc. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | 5 | * use this file except in compliance with the License. You may obtain a copy of |
| ... | ...@@ -153,6 +153,11 @@ | |
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | /** | |
| 157 | * The version number that should be passed into gwtOnLoad. | |
| 158 | */ | |
| 159 | private static final String EXPECTED_GWT_ONLOAD_VERSION = "1.5"; | |
| 160 | ||
| 156 | 161 | public static void launchExternalBrowser(TreeLogger logger, String location) { |
| 157 | 162 | // check GWT_EXTERNAL_BROWSER first, it overrides everything else |
| 158 | 163 | LowLevel.init(); |
| ... | ...@@ -361,6 +366,23 @@ | |
| 361 | 366 | } |
| 362 | 367 | |
| 363 | 368 | /** |
| 369 | * Report that gwtOnLoad was called with the wrong number of | |
| 370 | * arguments. | |
| 371 | * | |
| 372 | * @param numArgs number of arguments supplied | |
| 373 | */ | |
| 374 | protected void reportIncorrectGwtOnLoadInvocation(int numArgs) { | |
| 375 | getHost().getLogger().log( | |
| 376 | TreeLogger.ERROR, | |
| 377 | "Not enough arguments (" | |
| 378 | + numArgs | |
| 379 | + ") passed to external.gwtOnLoad(), expected (3); " | |
| 380 | + "your hosted mode bootstrap file may be out of date; " | |
| 381 | + "if you are using -noserver try recompiling and redeploying " | |
| 382 | + "your app"); | |
| 383 | } | |
| 384 | ||
| 385 | /** | |
| 364 | 386 | * Unload the specified module. |
| 365 | 387 | * |
| 366 | 388 | * @param moduleSpace a ModuleSpace instance to unload. |
| ... | ...@@ -373,6 +395,31 @@ | |
| 373 | 395 | + key.toString() + ")", null); |
| 374 | 396 | } |
| 375 | 397 | |
| 398 | /** | |
| 399 | * Validate that the supplied hosted.html version matches. | |
| 400 | * | |
| 401 | * This is to detect cases where users upgrade to a new version | |
| 402 | * but forget to update the generated hosted.html file. | |
| 403 | * | |
| 404 | * @param version version supplied by hosted.html file | |
| 405 | * @return true if the version is valid, false otherwise | |
| 406 | */ | |
| 407 | protected boolean validHostedHtmlVersion(String version) { | |
| 408 | if (!EXPECTED_GWT_ONLOAD_VERSION.equals(version)) { | |
| 409 | getHost().getLogger().log( | |
| 410 | TreeLogger.ERROR, | |
| 411 | "Invalid version number \"" | |
| 412 | + version | |
| 413 | + "\" passed to external.gwtOnLoad(), expected \"" | |
| 414 | + EXPECTED_GWT_ONLOAD_VERSION | |
| 415 | + "\"; your hosted mode bootstrap file may be out of date; " | |
| 416 | + "if you are using -noserver try recompiling and redeploying " | |
| 417 | + "your app"); | |
| 418 | return false; | |
| 419 | } | |
| 420 | return true; | |
| 421 | } | |
| 422 | ||
| 376 | 423 | private Composite buildLocationBar(Composite parent) { |
| 377 | 424 | Color white = new Color(null, 255, 255, 255); |
| 378 | 425 |
| ... | ...@@ -36,7 +36,7 @@ | |
| 36 | 36 | |
| 37 | 37 | private class ExternalObjectImpl implements ExternalObject { |
| 38 | 38 | |
| 39 | public boolean gwtOnLoad(int scriptObject, String moduleName) { | |
| 39 | public boolean gwtOnLoad(int scriptObject, String moduleName, String version) { | |
| 40 | 40 | try { |
| 41 | 41 | if (moduleName == null) { |
| 42 | 42 | // Indicates one or more modules are being unloaded. |
| ... | ...@@ -45,6 +45,10 @@ | |
| 45 | 45 | return true; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | if (!validHostedHtmlVersion(version)) { | |
| 49 | return false; | |
| 50 | } | |
| 51 | ||
| 48 | 52 | Object key = new Integer(scriptObject); |
| 49 | 53 | // Attach a new ModuleSpace to make it programmable. |
| 50 | 54 | // |
| ... | ...@@ -48,7 +48,7 @@ | |
| 48 | 48 | return this; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | public boolean gwtOnLoad(int scriptObject, String moduleName) { | |
| 51 | public boolean gwtOnLoad(int scriptObject, String moduleName, String version) { | |
| 52 | 52 | try { |
| 53 | 53 | if (moduleName == null) { |
| 54 | 54 | // Indicates one or more modules are being unloaded. |
| ... | ...@@ -56,6 +56,10 @@ | |
| 56 | 56 | return true; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | if (!validHostedHtmlVersion(version)) { | |
| 60 | return false; | |
| 61 | } | |
| 62 | ||
| 59 | 63 | // Attach a new ModuleSpace to make it programmable. |
| 60 | 64 | // |
| 61 | 65 | Integer key = new Integer(scriptObject); |
| ... | ...@@ -108,7 +112,7 @@ | |
| 108 | 112 | } |
| 109 | 113 | } |
| 110 | 114 | |
| 111 | private static final class GwtOnLoad implements DispatchMethod { | |
| 115 | private final class GwtOnLoad implements DispatchMethod { | |
| 112 | 116 | |
| 113 | 117 | public int invoke(int jsContext, int jsthis, int[] jsargs, int[] exception) { |
| 114 | 118 | int jsFalse = LowLevelSaf.toJsBoolean(jsContext, false); |
| ... | ...@@ -124,6 +128,7 @@ | |
| 124 | 128 | } |
| 125 | 129 | |
| 126 | 130 | if (jsargs.length < 2) { |
| 131 | reportIncorrectGwtOnLoadInvocation(jsargs.length); | |
| 127 | 132 | return jsFalse; |
| 128 | 133 | } |
| 129 | 134 | |
| ... | ...@@ -136,8 +141,19 @@ | |
| 136 | 141 | } |
| 137 | 142 | String moduleName = LowLevelSaf.toString(jsContext, jsargs[1]); |
| 138 | 143 | |
| 144 | /* | |
| 145 | * gwtOnLoad may or may not be called with a third argument indicating | |
| 146 | * which version of GWT the JavaScript bootstrap sequence assumes that | |
| 147 | * its talking to. | |
| 148 | */ | |
| 149 | String version = null; | |
| 150 | if (jsargs.length == 3 && !LowLevelSaf.isJsNull(jsContext, jsargs[2]) | |
| 151 | && LowLevelSaf.isJsString(jsContext, jsargs[2])) { | |
| 152 | version = LowLevelSaf.toString(jsContext, jsargs[2]); | |
| 153 | } | |
| 154 | ||
| 139 | 155 | boolean result = ((ExternalObject) thisObj).gwtOnLoad(jsargs[0], |
| 140 | moduleName); | |
| 156 | moduleName, version); | |
| 141 | 157 | // Native code eats the same ref it gave us. |
| 142 | 158 | return LowLevelSaf.toJsBoolean(jsContext, result); |
| 143 | 159 | } catch (Throwable e) { |
| ... | ...@@ -48,20 +48,6 @@ | |
| 48 | 48 | private final Serializer serializer; |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | * Constructs a <code>ClientSerializationStreamWriter</code> that does not | |
| 52 | * use a serialization policy file. | |
| 53 | * | |
| 54 | * @param serializer the {@link Serializer} to use | |
| 55 | */ | |
| 56 | public ClientSerializationStreamWriter(Serializer serializer) { | |
| 57 | this.serializer = serializer; | |
| 58 | this.moduleBaseURL = null; | |
| 59 | this.serializationPolicyStrongName = null; | |
| 60 | // Override the default version if no policy info is given. | |
| 61 | setVersion(SERIALIZATION_STREAM_VERSION_WITHOUT_SERIALIZATION_POLICY); | |
| 62 | } | |
| 63 | ||
| 64 | /** | |
| 65 | 51 | * Constructs a <code>ClientSerializationStreamWriter</code> using the |
| 66 | 52 | * specified module base URL and the serialization policy. |
| 67 | 53 | * |
| ... | ...@@ -85,10 +71,9 @@ | |
| 85 | 71 | super.prepareToWrite(); |
| 86 | 72 | encodeBuffer = new StringBuffer(); |
| 87 | 73 | |
| 88 | if (hasSerializationPolicyInfo()) { | |
| 89 | writeString(moduleBaseURL); | |
| 90 | writeString(serializationPolicyStrongName); | |
| 91 | } | |
| 74 | // Write serialization policy info | |
| 75 | writeString(moduleBaseURL); | |
| 76 | writeString(serializationPolicyStrongName); | |
| 92 | 77 | } |
| 93 | 78 | |
| 94 | 79 | @Override |
| ... | ...@@ -36,7 +36,6 @@ | |
| 36 | 36 | import com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException; |
| 37 | 37 | import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; |
| 38 | 38 | import com.google.gwt.user.client.rpc.SerializationException; |
| 39 | import com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader; | |
| 40 | 39 | import com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter; |
| 41 | 40 | import com.google.gwt.user.client.rpc.impl.RemoteServiceProxy; |
| 42 | 41 | import com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.ResponseReader; |
| ... | ...@@ -139,8 +138,6 @@ | |
| 139 | 138 | stob.addRootType(logger, icseType); |
| 140 | 139 | } |
| 141 | 140 | |
| 142 | private boolean enforceTypeVersioning; | |
| 143 | ||
| 144 | 141 | private JClassType serviceIntf; |
| 145 | 142 | |
| 146 | 143 | { |
| ... | ...@@ -236,9 +233,6 @@ | |
| 236 | 233 | sto.getTypeSerializerQualifiedName(serviceIntf)); |
| 237 | 234 | tsc.realize(logger); |
| 238 | 235 | |
| 239 | enforceTypeVersioning = Shared.shouldEnforceTypeVersioning(logger, | |
| 240 | context.getPropertyOracle()); | |
| 241 | ||
| 242 | 236 | String serializationPolicyStrongName = writeSerializationPolicyFile(logger, |
| 243 | 237 | context, sto); |
| 244 | 238 | |
| ... | ...@@ -362,12 +356,6 @@ | |
| 362 | 356 | w.indent(); |
| 363 | 357 | } |
| 364 | 358 | |
| 365 | if (!shouldEnforceTypeVersioning()) { | |
| 366 | w.println(streamWriterName + ".addFlags(" | |
| 367 | + ClientSerializationStreamReader.class.getName() | |
| 368 | + ".SERIALIZATION_STREAM_FLAGS_NO_TYPE_VERSIONING);"); | |
| 369 | } | |
| 370 | ||
| 371 | 359 | // Write the method name |
| 372 | 360 | w.println(streamWriterName + ".writeString(\"" + syncMethod.getName() |
| 373 | 361 | + "\");"); |
| ... | ...@@ -541,10 +529,6 @@ | |
| 541 | 529 | return composerFactory.createSourceWriter(ctx, printWriter); |
| 542 | 530 | } |
| 543 | 531 | |
| 544 | private boolean shouldEnforceTypeVersioning() { | |
| 545 | return enforceTypeVersioning; | |
| 546 | } | |
| 547 | ||
| 548 | 532 | private String writeSerializationPolicyFile(TreeLogger logger, |
| 549 | 533 | GeneratorContext ctx, SerializableTypeOracle sto) |
| 550 | 534 | throws UnableToCompleteException { |
| ... | ...@@ -49,14 +49,19 @@ | |
| 49 | 49 | * @param moduleName the name of the module to load, null if this is being |
| 50 | 50 | * unloaded |
| 51 | 51 | */ |
| 52 | public boolean gwtOnLoad(IDispatch frameWnd, String moduleName) { | |
| 52 | public boolean gwtOnLoad(IDispatch frameWnd, String moduleName, | |
| 53 | String version) { | |
| 53 | 54 | try { |
| 54 | 55 | if (moduleName == null) { |
| 55 | 56 | // Indicates one or more modules are being unloaded. |
| 56 | 57 | handleUnload(frameWnd); |
| 57 | 58 | return true; |
| 58 | 59 | } |
| 59 | ||
| 60 | ||
| 61 | if (!validHostedHtmlVersion(version)) { | |
| 62 | throw new HResultException(COM.E_INVALIDARG); | |
| 63 | } | |
| 64 | ||
| 60 | 65 | // set the module ID |
| 61 | 66 | int moduleID = ++nextModuleID; |
| 62 | 67 | Integer key = new Integer(moduleID); |
| ... | ...@@ -121,11 +126,17 @@ | |
| 121 | 126 | } else if (dispId == 1) { |
| 122 | 127 | if ((flags & COM.DISPATCH_METHOD) != 0) { |
| 123 | 128 | try { |
| 129 | if (params.length < 2) { | |
| 130 | reportIncorrectGwtOnLoadInvocation(params.length); | |
| 131 | throw new HResultException(COM.E_INVALIDARG); | |
| 132 | } | |
| 124 | 133 | IDispatch frameWnd = (params[0].getType() == COM.VT_DISPATCH) |
| 125 | 134 | ? params[0].getDispatch() : null; |
| 126 | 135 | String moduleName = (params[1].getType() == COM.VT_BSTR) |
| 127 | 136 | ? params[1].getString() : null; |
| 128 | boolean success = gwtOnLoad(frameWnd, moduleName); | |
| 137 | String version = (params.length > 2 && params[2].getType() == COM.VT_BSTR) | |
| 138 | ? params[2].getString() : null; | |
| 139 | boolean success = gwtOnLoad(frameWnd, moduleName, version); | |
| 129 | 140 | |
| 130 | 141 | // boolean return type |
| 131 | 142 | return new Variant(success); |
| ... | ...@@ -136,7 +147,7 @@ | |
| 136 | 147 | // property get on the method itself |
| 137 | 148 | try { |
| 138 | 149 | Method gwtOnLoadMethod = getClass().getMethod("gwtOnLoad", |
| 139 | new Class[] {IDispatch.class, String.class}); | |
| 150 | new Class[] {IDispatch.class, String.class, String.class}); | |
| 140 | 151 | MethodAdaptor methodAdaptor = new MethodAdaptor(gwtOnLoadMethod); |
| 141 | 152 | IDispatchImpl funcObj = new MethodDispatch(null, methodAdaptor); |
| 142 | 153 | IDispatch disp = new IDispatch(funcObj.getAddress()); |
| ... | ...@@ -170,7 +181,7 @@ | |
| 170 | 181 | OleAutomation window = null; |
| 171 | 182 | try { |
| 172 | 183 | window = new OleAutomation(frameWnd); |
| 173 | int[] dispID = window.getIDsOfNames(new String[] { propName }); | |
| 184 | int[] dispID = window.getIDsOfNames(new String[] {propName}); | |
| 174 | 185 | if (dispID == null) { |
| 175 | 186 | throw new RuntimeException("No such property " + propName); |
| 176 | 187 | } |
| ... | ...@@ -203,7 +214,7 @@ | |
| 203 | 214 | OleAutomation window = null; |
| 204 | 215 | try { |
| 205 | 216 | window = new OleAutomation(frameWnd); |
| 206 | int[] dispID = window.getIDsOfNames(new String[] { propName }); | |
| 217 | int[] dispID = window.getIDsOfNames(new String[] {propName}); | |
| 207 | 218 | if (dispID == null) { |
| 208 | 219 | throw new RuntimeException("No such property " + propName); |
| 209 | 220 | } |
| ... | ...@@ -75,7 +75,7 @@ | |
| 75 | 75 | * Safari. |
| 76 | 76 | */ |
| 77 | 77 | interface ExternalObject { |
| 78 | boolean gwtOnLoad(int scriptGlobalObject, String moduleName); | |
| 78 | boolean gwtOnLoad(int scriptGlobalObject, String moduleName, String version); | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
| ... | ...@@ -1,5 +1,5 @@ | |
| 1 | 1 | <!-- --> |
| 2 | <!-- Copyright 2007 Google Inc. --> | |
| 2 | <!-- Copyright 2008 Google Inc. --> | |
| 3 | 3 | <!-- Licensed under the Apache License, Version 2.0 (the "License"); you --> |
| 4 | 4 | <!-- may not use this file except in compliance with the License. You may --> |
| 5 | 5 | <!-- may obtain a copy of the License at --> |
| ... | ...@@ -20,15 +20,6 @@ | |
| 20 | 20 | <inherits name="com.google.gwt.http.HTTP"/> |
| 21 | 21 | |
| 22 | 22 | <!-- |
| 23 | Declare a property to determine whether or not RPC type versioning | |
| 24 | should be enforced. | |
| 25 | --> | |
| 26 | <define-property name="gwt.enforceRPCTypeVersioning" values="true,false" /> | |
| 27 | ||
| 28 | <!-- Default RPC versioning to be on. --> | |
| 29 | <set-property name="gwt.enforceRPCTypeVersioning" value="true"/> | |
| 30 | ||
| 31 | <!-- | |
| 32 | 23 | Declare a property to determine whether warnings for final instance |
| 33 | 24 | fields should be suppressed. |
| 34 | 25 | --> |
| ... | ...@@ -27,11 +27,6 @@ | |
| 27 | 27 | import java.util.Locale; |
| 28 | 28 | |
| 29 | 29 | class Shared { |
| 30 | /** | |
| 31 | * Property used to control whether or not the RPC system will enforce the | |
| 32 | * versioning scheme or not. | |
| 33 | */ | |
| 34 | static final String RPC_PROP_ENFORCE_TYPE_VERSIONING = "gwt.enforceRPCTypeVersioning"; | |
| 35 | 30 | |
| 36 | 31 | /** |
| 37 | 32 | * Property used to control whether or not the RPC system will emit warnings |
| ... | ...@@ -58,16 +53,6 @@ | |
| 58 | 53 | } |
| 59 | 54 | |
| 60 | 55 | /** |
| 61 | * Returns <code>true</code> if the generated code should enforce type | |
| 62 | * versioning. | |
| 63 | */ | |
| 64 | static boolean shouldEnforceTypeVersioning(TreeLogger logger, | |
| 65 | PropertyOracle propertyOracle) { | |
| 66 | return getBooleanProperty(logger, propertyOracle, | |
| 67 | RPC_PROP_ENFORCE_TYPE_VERSIONING, true); | |
| 68 | } | |
| 69 | ||
| 70 | /** | |
| 71 | 56 | * Returns <code>true</code> if warnings should not be emitted for final |
| 72 | 57 | * fields in serializable types. |
| 73 | 58 | */ |
| ... | ...@@ -15,6 +15,7 @@ | |
| 15 | 15 | */ |
| 16 | 16 | package com.google.gwt.user.server.rpc.impl; |
| 17 | 17 | |
| 18 | import com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException; | |
| 18 | 19 | import com.google.gwt.user.client.rpc.SerializationException; |
| 19 | 20 | import com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader; |
| 20 | 21 | import com.google.gwt.user.server.rpc.RPC; |
| ... | ...@@ -381,23 +382,27 @@ | |
| 381 | 382 | |
| 382 | 383 | super.prepareToRead(encodedTokens); |
| 383 | 384 | |
| 385 | // Check the RPC version number sent by the client | |
| 386 | if (getVersion() != SERIALIZATION_STREAM_VERSION) { | |
| 387 | throw new IncompatibleRemoteServiceException("Expecting version " | |
| 388 | + SERIALIZATION_STREAM_VERSION + " from client, got " + getVersion() | |
| 389 | + "."); | |
| 390 | } | |
| 391 | ||
| 384 | 392 | // Read the type name table |
| 385 | 393 | // |
| 386 | 394 | deserializeStringTable(); |