| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Google Web Toolkit
Revision: 3589
Author: scottb@google.com
Date: 28 Aug 2008 18:27:21
Changes:Merging releases/1.5 into trunk
svn merge -r3505:3549 https://google-web-toolkit.googlecode.com/svn/releases/1.5 .
Files:| ... | ...@@ -40,6 +40,23 @@ | |
| 40 | 40 | historyListeners.add(listener); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | /** | |
| 44 | * Fires the {@link HistoryListener#onHistoryChanged(String)} event to all | |
| 45 | * listeners with the given token. | |
| 46 | */ | |
| 47 | public static void fireHistoryChangedImpl(String historyToken) { | |
| 48 | // TODO: replace this copy when a more general solution to event handlers | |
| 49 | // wanting to remove themselves from the listener list is implemented. | |
| 50 | ||
| 51 | // This is necessary to avoid a CurrentModificationException in hosted | |
| 52 | // mode, as the listeners may try to remove themselves from the list while | |
| 53 | // it is being iterated, such as in HistoryTest. | |
| 54 | HistoryListener[] listenersToInvoke = historyListeners.toArray(new HistoryListener[historyListeners.size()]); | |
| 55 | for (HistoryListener listener : listenersToInvoke) { | |
| 56 | listener.onHistoryChanged(historyToken); | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 43 | 60 | public static native String getToken() /*-{ |
| 44 | 61 | return $wnd.__gwt_historyToken || ""; |
| 45 | 62 | }-*/; |
| ... | ...@@ -75,19 +92,6 @@ | |
| 75 | 92 | } |
| 76 | 93 | } |
| 77 | 94 | |
| 78 | private static void fireHistoryChangedImpl(String historyToken) { | |
| 79 | // TODO: replace this copy when a more general solution to event handlers | |
| 80 | // wanting to remove themselves from the listener list is implemented. | |
| 81 | ||
| 82 | // This is necessary to avoid a CurrentModificationException in hosted | |
| 83 | // mode, as the listeners may try to remove themselves from the list while | |
| 84 | // it is being iterated, such as in HistoryTest. | |
| 85 | HistoryListener[] listenersToInvoke = historyListeners.toArray(new HistoryListener[historyListeners.size()]); | |
| 86 | for (HistoryListener listener : listenersToInvoke) { | |
| 87 | listener.onHistoryChanged(historyToken); | |
| 88 | } | |
| 89 | } | |
| 90 | ||
| 91 | 95 | public abstract boolean init(); |
| 92 | 96 | |
| 93 | 97 | public final void newItem(String historyToken, boolean issueEvent) { |
| ... | ...@@ -1,85 +0,0 @@ | |
| 1 | /* | |
| 2 | * Copyright 2007 Google Inc. | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not | |
| 5 | * use this file except in compliance with the License. You may obtain a copy of | |
| 6 | * the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
| 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
| 13 | * License for the specific language governing permissions and limitations under | |
| 14 | * the License. | |
| 15 | */ | |
| 16 | ||
| 17 | package com.google.gwt.user.rebind.rpc.testcases.client; | |
| 18 | ||
| 19 | import com.google.gwt.user.client.rpc.IsSerializable; | |
| 20 | ||
| 21 | /** | |
| 22 | * Used to test that the | |
| 23 | * {@link com.google.gwt.user.rebind.rpc.SerializableTypeOracleBuilder SerializableTypeOracleBuilder} | |
| 24 | * will handle covariant arrays correctly. For example, the service interface | |
| 25 | * below should be able to handle the following covariant array types: AA[], | |
| 26 | * A[], BB[], B[], CC[], C[], DD[], D[]. Notice that E[] should not be included. | |
| 27 | */ | |
| 28 | public interface CovariantArrays { | |
| 29 | /** | |
| 30 | * Not serializable. | |
| 31 | */ | |
| 32 | class A implements DD { | |
| 33 | } | |
| 34 | ||
| 35 | /** | |
| 36 | * Not serializable. | |
| 37 | */ | |
| 38 | interface AA { | |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * Auto serializable. | |
| 43 | */ | |
| 44 | class B extends A implements IsSerializable { | |
| 45 | } | |
| 46 | ||
| 47 | /** | |
| 48 | * Not serializable. | |
| 49 | */ | |
| 50 | interface BB extends AA { | |
| 51 | } | |
| 52 | ||
| 53 | /** | |
| 54 | * Not auto serializable due to bad field. | |
| 55 | */ | |
| 56 | class C extends B { | |
| 57 | Object field; | |
| 58 | } | |
| 59 | ||
| 60 | /** | |
| 61 | * Not serializable. | |
| 62 | */ | |
| 63 | interface CC extends AA { | |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * Auto serializable. | |
| 68 | */ | |
| 69 | class D extends C implements IsSerializable { | |
| 70 | } | |
| 71 | ||
| 72 | /** | |
| 73 | * Not serializable. | |
| 74 | */ | |
| 75 | interface DD extends BB, CC { | |
| 76 | } | |
| 77 | ||
| 78 | /** | |
| 79 | * Not auto serializable because super class is not. | |
| 80 | */ | |
| 81 | class E extends C { | |
| 82 | } | |
| 83 | ||
| 84 | AA[] getAs(); | |
| 85 | } |
| ... | ...@@ -667,13 +667,14 @@ | |
| 667 | 667 | count++; |
| 668 | 668 | } |
| 669 | 669 | } |
| 670 | // all blank delimiters at the end are supposed to disappear if maxMatch ==0 | |
| 670 | // all blank delimiters at the end are supposed to disappear if maxMatch == 0 | |
| 671 | 671 | if (maxMatch == 0) { |
| 672 | for (var i = out.length - 1; i >= 0; i--) { | |
| 673 | if(out[i] != "") { | |
| 674 | out.splice(i + 1,out.length - (i + 1)); | |
| 675 | break; | |
| 676 | } | |
| 672 | var lastNonEmpty = out.length; | |
| 673 | while (lastNonEmpty > 0 && out[lastNonEmpty - 1] == "") { | |
| 674 | --lastNonEmpty; | |
| 675 | } | |
| 676 | if (lastNonEmpty < out.length) { | |
| 677 | out.splice(lastNonEmpty, out.length - lastNonEmpty); | |
| 677 | 678 | } |
| 678 | 679 | } |
| 679 | 680 | var jr = @java.lang.String::__createArray(I)(out.length); |
| ... | ...@@ -18,6 +18,13 @@ | |
| 18 | 18 | import com.google.gwt.user.client.rpc.CollectionsTestService; |
| 19 | 19 | import com.google.gwt.user.client.rpc.TestSetFactory; |
| 20 | 20 | import com.google.gwt.user.client.rpc.TestSetValidator; |
| 21 | import com.google.gwt.user.client.rpc.TestSetFactory.MarkerTypeArrayList; | |
| 22 | import com.google.gwt.user.client.rpc.TestSetFactory.MarkerTypeArraysAsList; | |
| 23 | import com.google.gwt.user.client.rpc.TestSetFactory.MarkerTypeHashMap; | |
| 24 | import com.google.gwt.user.client.rpc.TestSetFactory.MarkerTypeHashSet; | |
| 25 | import com.google.gwt.user.client.rpc.TestSetFactory.MarkerTypeLinkedHashMap; | |
| 26 | import com.google.gwt.user.client.rpc.TestSetFactory.MarkerTypeLinkedHashSet; | |
| 27 | import com.google.gwt.user.client.rpc.TestSetFactory.MarkerTypeVector; | |
| 21 | 28 | |
| 22 | 29 | import java.sql.Time; |
| 23 | 30 | import java.sql.Timestamp; |
| ... | ...@@ -27,6 +34,7 @@ | |
| 27 | 34 | import java.util.HashMap; |
| 28 | 35 | import java.util.HashSet; |
| 29 | 36 | import java.util.LinkedHashMap; |
| 37 | import java.util.LinkedHashSet; | |
| 30 | 38 | import java.util.List; |
| 31 | 39 | import java.util.Vector; |
| 32 | 40 | |
| ... | ...@@ -40,8 +48,8 @@ | |
| 40 | 48 | return Arrays.asList(values).toString(); |
| 41 | 49 | } |
| 42 | 50 | |
| 43 | @SuppressWarnings("unchecked") | |
| 44 | public ArrayList echo(ArrayList list) throws CollectionsTestServiceException { | |
| 51 | public ArrayList<MarkerTypeArrayList> echo(ArrayList<MarkerTypeArrayList> list) | |
| 52 | throws CollectionsTestServiceException { | |
| 45 | 53 | if (!TestSetValidator.isValid(list)) { |
| 46 | 54 | throw new CollectionsTestServiceException(); |
| 47 | 55 | } |
| ... | ...@@ -122,17 +130,6 @@ | |
| 122 | 130 | return actual; |
| 123 | 131 | } |
| 124 | 132 | |
| 125 | public java.sql.Date[] echo(java.sql.Date[] actual) | |
| 126 | throws CollectionsTestServiceException { | |
| 127 | java.sql.Date[] expected = TestSetFactory.createSqlDateArray(); | |
| 128 | if (!TestSetValidator.equals(expected, actual)) { | |
| 129 | throw new CollectionsTestServiceException("expected: " | |
| 130 | + toString(expected) + " actual: " + toString(actual)); | |
| 131 | } | |
| 132 | ||
| 133 | return actual; | |
| 134 | } | |
| 135 | ||
| 136 | 133 | public double[] echo(double[] actual) throws CollectionsTestServiceException { |
| 137 | 134 | double[] expected = TestSetFactory.createPrimitiveDoubleArray(); |
| 138 | 135 | if (!TestSetValidator.equals(expected, actual)) { |
| ... | ...@@ -173,9 +170,10 @@ | |
| 173 | 170 | return actual; |
| 174 | 171 | } |
| 175 | 172 | |
| 176 | @SuppressWarnings("unchecked") | |
| 177 | public HashMap echo(HashMap actual) throws CollectionsTestServiceException { | |
| 178 | HashMap expected = TestSetFactory.createHashMap(); | |
| 173 | public HashMap<String, MarkerTypeHashMap> echo( | |
| 174 | HashMap<String, MarkerTypeHashMap> actual) | |
| 175 | throws CollectionsTestServiceException { | |
| 176 | HashMap<String, MarkerTypeHashMap> expected = TestSetFactory.createHashMap(); | |
| 179 | 177 | if (!TestSetValidator.isValid(expected, actual)) { |
| 180 | 178 | throw new CollectionsTestServiceException("expected: " |
| 181 | 179 | + expected.toString() + " actual: " + actual.toString()); |
| ... | ...@@ -184,20 +182,9 @@ | |
| 184 | 182 | return actual; |
| 185 | 183 | } |
| 186 | 184 | |
| 187 | @SuppressWarnings("unchecked") | |
| 188 | public LinkedHashMap echo(LinkedHashMap actual) | |
| 185 | public HashSet<MarkerTypeHashSet> echo(HashSet<MarkerTypeHashSet> actual) | |
| 189 | 186 | throws CollectionsTestServiceException { |
| 190 | HashMap expected = TestSetFactory.createLinkedHashMap(); | |
| 191 | if (!TestSetValidator.isValid(expected, actual)) { | |
| 192 | throw new CollectionsTestServiceException("expected:" | |
| 193 | + expected.toString() + " actual:" + actual.toString()); | |
| 194 | } | |
| 195 | return actual; | |
| 196 | } | |
| 197 | ||
| 198 | @SuppressWarnings("unchecked") | |
| 199 | public HashSet echo(HashSet actual) throws CollectionsTestServiceException { | |
| 200 | HashSet expected = TestSetFactory.createHashSet(); | |
| 187 | HashSet<MarkerTypeHashSet> expected = TestSetFactory.createHashSet(); | |
| 201 | 188 | if (!TestSetValidator.isValid(expected, actual)) { |
| 202 | 189 | throw new CollectionsTestServiceException("expected: " |
| 203 | 190 | + expected.toString() + " actual: " + actual.toString()); |
| ... | ...@@ -232,6 +219,39 @@ | |
| 232 | 219 | return actual; |
| 233 | 220 | } |
| 234 | 221 | |
| 222 | public java.sql.Date[] echo(java.sql.Date[] actual) | |
| 223 | throws CollectionsTestServiceException { | |
| 224 | java.sql.Date[] expected = TestSetFactory.createSqlDateArray(); | |
| 225 | if (!TestSetValidator.equals(expected, actual)) { | |
| 226 | throw new CollectionsTestServiceException("expected: " | |
| 227 | + toString(expected) + " actual: " + toString(actual)); | |
| 228 | } | |
| 229 | ||
| 230 | return actual; | |
| 231 | } | |
| 232 | ||
| 233 | public LinkedHashMap<String, MarkerTypeLinkedHashMap> echo( | |
| 234 | LinkedHashMap<String, MarkerTypeLinkedHashMap> actual) | |
| 235 | throws CollectionsTestServiceException { | |
| 236 | LinkedHashMap<String, MarkerTypeLinkedHashMap> expected = TestSetFactory.createLinkedHashMap(); | |
| 237 | if (!TestSetValidator.isValid(expected, actual)) { | |
| 238 | throw new CollectionsTestServiceException("expected: " | |
| 239 | + expected.toString() + " actual: " + actual.toString()); | |
| 240 | } | |
| 241 | return actual; | |
| 242 | } | |
| 243 | ||
| 244 | public LinkedHashSet<MarkerTypeLinkedHashSet> echo( | |
| 245 | LinkedHashSet<MarkerTypeLinkedHashSet> actual) | |
| 246 | throws CollectionsTestServiceException { | |
| 247 | LinkedHashSet<MarkerTypeLinkedHashSet> expected = TestSetFactory.createLinkedHashSet(); | |
| 248 | if (!TestSetValidator.isValid(expected, actual)) { | |
| 249 | throw new CollectionsTestServiceException("expected: " | |
| 250 | + expected.toString() + " actual: " + actual.toString()); | |
| 251 | } | |
| 252 | return actual; | |
| 253 | } | |
| 254 | ||
| 235 | 255 | public long[] echo(long[] actual) throws CollectionsTestServiceException { |
| 236 | 256 | long[] expected = TestSetFactory.createPrimitiveLongArray(); |
| 237 | 257 | if (!TestSetValidator.equals(expected, actual)) { |
| ... | ...@@ -308,9 +328,9 @@ | |
| 308 | 328 | return actual; |
| 309 | 329 | } |
| 310 | 330 | |
| 311 | @SuppressWarnings("unchecked") | |
| 312 | public Vector echo(Vector actual) throws CollectionsTestServiceException { | |
| 313 | Vector expected = TestSetFactory.createVector(); | |
| 331 | public Vector<MarkerTypeVector> echo(Vector<MarkerTypeVector> actual) | |
| 332 | throws CollectionsTestServiceException { | |
| 333 | Vector<MarkerTypeVector> expected = TestSetFactory.createVector(); | |
| 314 | 334 | if (!TestSetValidator.isValid(expected, actual)) { |
| 315 | 335 | throw new CollectionsTestServiceException("expected: " |
| 316 | 336 | + expected.toString() + " actual: " + actual.toString()); |
| ... | ...@@ -319,12 +339,8 @@ | |
| 319 | 339 | return actual; |
| 320 | 340 | } |
| 321 | 341 | |
| 322 | /** | |
| 323 | * Return the result of Arrays.asList(Object[]) to force an | |
| 324 | * InvocationException on the client. | |
| 325 | */ | |
| 326 | @SuppressWarnings("unchecked") | |
| 327 | public List echoArraysAsList(List value) | |
| 342 | public List<MarkerTypeArraysAsList> echoArraysAsList( | |
| 343 | List<MarkerTypeArraysAsList> value) | |
| 328 | 344 | throws CollectionsTestServiceException { |
| 329 | 345 | if (!TestSetValidator.isValidAsList(value)) { |
| 330 | 346 | throw new CollectionsTestServiceException(); |
| ... | ...@@ -103,43 +103,37 @@ | |
| 103 | 103 | */ |
| 104 | 104 | public static String readContentAsUtf8(HttpServletRequest request) |
| 105 | 105 | throws IOException, ServletException { |
| 106 | return readContentAsUtf8(request, true); | |
| 107 | } | |
| 108 | ||
| 109 | /** | |
| 110 | * Returns the content of an {@link HttpServletRequest} by decoding it using | |
| 111 | * the UTF-8 charset. | |
| 112 | * | |
| 113 | * @param request the servlet request whose content we want to read | |
| 114 | * @param checkHeaders Specify 'true' to check the Content-Type header to see | |
| 115 | * that it matches the expected value 'text/x-gwt-rpc' and the | |
| 116 | * content encoding is UTF-8. Disabling this check may allow some | |
| 117 | * types of cross type security attacks. | |
| 118 | * @return the content of an {@link HttpServletRequest} by decoding it using | |
| 119 | * the UTF-8 charset | |
| 120 | * @throws IOException if the requests input stream cannot be accessed, read | |
| 121 | * from or closed | |
| 122 | * @throws ServletException if the content length of the request is not | |
| 123 | * specified of if the request's content type is not | |
| 124 | * 'text/x-gwt-rpc' and 'charset=utf-8' | |
| 125 | */ | |
| 126 | public static String readContentAsUtf8(HttpServletRequest request, | |
| 127 | boolean checkHeaders) throws IOException, ServletException { | |
| 106 | 128 | int contentLength = request.getContentLength(); |
| 107 | 129 | if (contentLength == -1) { |
| 108 | 130 | // Content length must be known. |
| 109 | 131 | throw new ServletException("Content-Length must be specified"); |
| 110 | 132 | } |
| 111 | 133 | |
| 112 | String contentType = request.getContentType(); | |
| 113 | boolean contentTypeIsOkay = false; | |
| 114 | // Content-Type must be specified. | |
| 115 | if (contentType != null) { | |
| 116 | contentType = contentType.toLowerCase(); | |
| 117 | /* | |
| 118 | * The Content-Type must be text/x-gwt-rpc. | |
| 119 | * | |
| 120 | * NOTE:We use startsWith because some servlet engines, i.e. Tomcat, do | |
| 121 | * not remove the charset component but others do. | |
| 122 | */ | |
| 123 | if (contentType.startsWith(EXPECTED_CONTENT_TYPE)) { | |
| 124 | String characterEncoding = request.getCharacterEncoding(); | |
| 125 | if (characterEncoding != null) { | |
| 126 | /* | |
| 127 | * TODO: It would seem that we should be able to use equalsIgnoreCase | |
| 128 | * here instead of indexOf. Need to be sure that servlet engines | |
| 129 | * return a properly parsed character encoding string if we decide to | |
| 130 | * make this change. | |
| 131 | */ | |
| 132 | if (characterEncoding.toLowerCase().indexOf( | |
| 133 | CHARSET_UTF8.toLowerCase()) != -1) { | |
| 134 | contentTypeIsOkay = true; | |
| 135 | } | |
| 136 | } | |
| 137 | } | |
| 138 | } | |
| 139 | ||
| 140 | if (!contentTypeIsOkay) { | |
| 141 | throw new ServletException("Content-Type must be '" | |
| 142 | + EXPECTED_CONTENT_TYPE + "' with '" + EXPECTED_CHARSET + "'."); | |
| 134 | if (checkHeaders) { | |
| 135 | checkContentType(request); | |
| 136 | checkCharacterEncoding(request); | |
| 143 | 137 | } |
| 144 | 138 | |
| 145 | 139 | InputStream in = request.getInputStream(); |
| ... | ...@@ -266,6 +260,67 @@ | |
| 266 | 260 | } |
| 267 | 261 | } |
| 268 | 262 | |
| 263 | /** | |
| 264 | * Performs validation of the character encoding. | |
| 265 | * | |
| 266 | * @param request the incoming request. | |
| 267 | * @throws ServletException if requests encoding is not UTF-8 | |
| 268 | */ | |
| 269 | private static void checkCharacterEncoding(HttpServletRequest request) | |
| 270 | throws ServletException { | |
| 271 | boolean encodingOkay = false; | |
| 272 | String characterEncoding = request.getCharacterEncoding(); | |
| 273 | if (characterEncoding != null) { | |
| 274 | /* | |
| 275 | * TODO: It would seem that we should be able to use equalsIgnoreCase here | |
| 276 | * instead of indexOf. Need to be sure that servlet engines return a | |
| 277 | * properly parsed character encoding string if we decide to make this | |
| 278 | * change. | |
| 279 | */ | |
| 280 | if (characterEncoding.toLowerCase().indexOf(CHARSET_UTF8.toLowerCase()) != -1) { | |
| 281 | encodingOkay = true; | |
| 282 | } | |
| 283 | } | |
| 284 | ||
| 285 | if (!encodingOkay) { | |
| 286 | throw new ServletException("Character Encoding is '" | |
| 287 | + (characterEncoding == null ? "(null)" : characterEncoding) | |
| 288 | + "'. Expected '" + EXPECTED_CHARSET + "'"); | |
| 289 | } | |
| 290 | } | |
| 291 | ||
| 292 | /** | |
| 293 | * Performs Content-Type validation of the incoming request. | |
| 294 | * | |
| 295 | * @param request the incoming request. | |
| 296 | * @throws ServletException if the request's content type is not | |
| 297 | * 'text/x-gwt-rpc' | |
| 298 | */ | |
| 299 | private static void checkContentType(HttpServletRequest request) | |
| 300 | throws ServletException { | |
| 301 | String contentType = request.getContentType(); | |
| 302 | boolean contentTypeIsOkay = false; | |
| 303 | ||
| 304 | if (contentType != null) { | |
| 305 | contentType = contentType.toLowerCase(); | |
| 306 | /* | |
| 307 | * The Content-Type must be text/x-gwt-rpc. | |
| 308 | * | |
| 309 | * NOTE:We use startsWith because some servlet engines, i.e. Tomcat, do | |
| 310 | * not remove the charset component but others do. | |
| 311 | */ | |
| 312 | if (contentType.startsWith(EXPECTED_CONTENT_TYPE)) { | |
| 313 | contentTypeIsOkay = true; | |
| 314 | } | |
| 315 | } | |
| 316 | ||
| 317 | if (!contentTypeIsOkay) { | |
| 318 | throw new ServletException("Content-Type was '" | |
| 319 | + (contentType == null ? "(null)" : contentType) + "'. Expected '" | |
| 320 | + EXPECTED_CONTENT_TYPE + "'."); | |
| 321 | } | |
| 322 | } | |
| 323 | ||
| 269 | 324 | private RPCServletUtils() { |
| 270 | 325 | // Not instantiable |
| 271 | 326 | } |
| ... | ...@@ -28,6 +28,49 @@ | |
| 28 | 28 | */ |
| 29 | 29 | public class JsniConstructorTest extends GWTTestCase { |
| 30 | 30 | |
| 31 | private interface A1 { | |
| 32 | void a1(); | |
| 33 | } | |
| 34 | ||
| 35 | private interface A2 extends A1 { | |
| 36 | void a2(); | |
| 37 | } | |
| 38 | ||
| 39 | private interface A3 { | |
| 40 | void a3(); | |
| 41 | } | |
| 42 | ||
| 43 | private static abstract class C1 implements A2 { | |
| 44 | static void s1() { | |
| 45 | } | |
| 46 | ||
| 47 | public abstract void c1(); | |
| 48 | } | |
| 49 | ||
| 50 | private static class C2 extends C1 implements A3 { | |
| 51 | static void s2() { | |
| 52 | } | |
| 53 | ||
| 54 | public void a1() { | |
| 55 | } | |
| 56 | ||
| 57 | public void a2() { | |
| 58 | } | |
| 59 | ||
| 60 | public void a3() { | |
| 61 | } | |
| 62 | ||
| 63 | public void c1() { | |
| 64 | } | |
| 65 | ||
| 66 | public void c2() { | |
| 67 | } | |
| 68 | ||
| 69 | public String toString() { | |
| 70 | return null; | |
| 71 | } | |
| 72 | } | |
| 73 | ||
| 31 | 74 | @Override |
| 32 | 75 | public String getModuleName() { |
| 33 | 76 | return "com.google.gwt.dev.jjs.CompilerSuite"; |
| ... | ...@@ -45,7 +88,7 @@ | |
| 45 | 88 | } catch (Throwable t) { |
| 46 | 89 | fail("Expecting a StaticObjectException, got a " + t.getClass().getName()); |
| 47 | 90 | } |
| 48 | ||
| 91 | ||
| 49 | 92 | try { |
| 50 | 93 | staticArg(true); |
| 51 | 94 | fail("Should have thrown a runtime exception"); |
| ... | ...@@ -55,7 +98,35 @@ | |
| 55 | 98 | fail("Expecting a RuntimeException, got a " + t.getClass().getName()); |
| 56 | 99 | } |
| 57 | 100 | } |
| 58 | ||
| 101 | ||
| 102 | public native void testInheritedMethodRef() /*-{ | |
| 103 | @com.google.gwt.dev.jjs.test.JsniConstructorTest.C1::s1()(); | |
| 104 | @com.google.gwt.dev.jjs.test.JsniConstructorTest.C2::s1()(); | |
| 105 | @com.google.gwt.dev.jjs.test.JsniConstructorTest.C2::s2()(); | |
| 106 | ||
| 107 | var o = @com.google.gwt.dev.jjs.test.JsniConstructorTest.C2::new()(); | |
| 108 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.A1::a1()(); | |
| 109 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.A2::a1()(); | |
| 110 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.C1::a1()(); | |
| 111 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.C2::a1()(); | |
| 112 | ||
| 113 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.A2::a2()(); | |
| 114 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.C1::a2()(); | |
| 115 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.C2::a2()(); | |
| 116 | ||
| 117 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.A3::a3()(); | |
| 118 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.C2::a3()(); | |
| 119 | ||
| 120 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.C1::c1()(); | |
| 121 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.C2::c1()(); | |
| 122 | ||
| 123 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.C2::c2()(); | |
| 124 | ||
| 125 | o.@java.lang.Object::toString()(); | |
| 126 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.C1::toString()(); | |
| 127 | o.@com.google.gwt.dev.jjs.test.JsniConstructorTest.C2::toString()(); | |
| 128 | }-*/; | |
| 129 | ||
| 59 | 130 | public void testJsniConstructors() { |
| 60 | 131 | StaticObject o = staticArg(1); |
| 61 | 132 | assertEquals(1, o.foo()); |
| ... | ...@@ -83,43 +154,45 @@ | |
| 83 | 154 | } |
| 84 | 155 | |
| 85 | 156 | private native InstanceObject instanceArg(StaticObject obj, int i) /*-{ |
| 86 | return @com.google.gwt.dev.jjs.test.StaticObject.InstanceObject::new(Lcom/google/gwt/dev/jjs/test/StaticObject;I)(obj,i); | |
| 157 | return @com.google.gwt.dev.jjs.test.StaticObject.InstanceObject::new(Lcom/google/gwt/dev/jjs/test/StaticObject;I)(obj,i); | |
| 87 | 158 | }-*/; |
| 88 | 159 | |
| 89 | private native NestedInstanceObject nestedInstanceArg(InstanceObject obj, int i) /*-{ | |
| 90 | return @com.google.gwt.dev.jjs.test.StaticObject.InstanceObject.NestedInstanceObject::new(Lcom/google/gwt/dev/jjs/test/StaticObject$InstanceObject;I)(obj,i); | |
| 160 | private native NestedInstanceObject nestedInstanceArg(InstanceObject obj, | |
| 161 | int i) /*-{ | |
| 162 | return @com.google.gwt.dev.jjs.test.StaticObject.InstanceObject.NestedInstanceObject::new(Lcom/google/gwt/dev/jjs/test/StaticObject$InstanceObject;I)(obj,i); | |
| 91 | 163 | }-*/; |
| 92 | 164 | |
| 93 | 165 | private native NoArgObject noArg() /*-{ |
| 94 | return @com.google.gwt.dev.jjs.test.StaticObject.NoArgObject::new()(); | |
| 166 | return @com.google.gwt.dev.jjs.test.StaticObject.NoArgObject::new()(); | |
| 95 | 167 | }-*/; |
| 96 | 168 | |
| 97 | 169 | private native NoInitObject noInit() /*-{ |
| 98 | return @com.google.gwt.dev.jjs.test.StaticObject.NoInitObject::new()(); | |
| 170 | return @com.google.gwt.dev.jjs.test.StaticObject.NoInitObject::new()(); | |
| 99 | 171 | }-*/; |
| 100 | 172 | |
| 101 | 173 | private native InstanceObject passAndReturnInstance(StaticObject obj, int i) /*-{ |
| 102 | var f = @com.google.gwt.dev.jjs.test.StaticObject.InstanceObject::new(Lcom/google/gwt/dev/jjs/test/StaticObject;I); | |
| 103 | return f.call(null, obj, i); | |
| 174 | var f = @com.google.gwt.dev.jjs.test.StaticObject.InstanceObject::new(Lcom/google/gwt/dev/jjs/test/StaticObject;I); | |
| 175 | return f.call(null, obj, i); | |
| 104 | 176 | }-*/; |
| 105 | 177 | |
| 106 | 178 | private native StaticObject passAndReturnStatic(int i) /*-{ |
| 107 | var f = @com.google.gwt.dev.jjs.test.StaticObject::new(I); | |
| 108 | return f(i); | |
| 179 | var f = @com.google.gwt.dev.jjs.test.StaticObject::new(I); | |
| 180 | return f(i); | |
| 109 | 181 | }-*/; |
| 110 | 182 | |
| 111 | 183 | /** |
| 112 | 184 | * Calls a constructor that always throws an exception. |
| 113 | 185 | */ |
| 114 | private native StaticObject staticArg(boolean throwRuntime) throws StaticObjectException /*-{ | |
| 115 | return @com.google.gwt.dev.jjs.test.StaticObject::new(Z)(throwRuntime); | |
| 186 | private native StaticObject staticArg(boolean throwRuntime) | |
| 187 | throws StaticObjectException /*-{ | |
| 188 | return @com.google.gwt.dev.jjs.test.StaticObject::new(Z)(throwRuntime); | |
| 116 | 189 | }-*/; |
| 117 | ||
| 190 | ||
| 118 | 191 | private native StaticObject staticArg(int i) /*-{ |
| 119 | return @com.google.gwt.dev.jjs.test.StaticObject::new(I)(i); | |
| 192 | return @com.google.gwt.dev.jjs.test.StaticObject::new(I)(i); | |
| 120 | 193 | }-*/; |
| 121 | 194 | |
| 122 | 195 | private native StaticInnerObject staticInnerArg(int i) /*-{ |
| 123 | return @com.google.gwt.dev.jjs.test.StaticObject.StaticInnerObject::new(I)(i); | |
| 196 | return @com.google.gwt.dev.jjs.test.StaticObject.StaticInnerObject::new(I)(i); | |
| 124 | 197 | }-*/; |
| 125 | 198 | } |
| ... | ...@@ -15,9 +15,29 @@ | |
| 15 | 15 | */ |
| 16 | 16 | package com.google.gwt.user.server.rpc; |
| 17 | 17 | |
| 18 | import java.io.IOException; | |
| 19 | ||
| 20 | import javax.servlet.ServletException; | |
| 21 | import javax.servlet.http.HttpServletRequest; | |
| 22 | import javax.servlet.http.HttpServletResponse; | |
| 23 | ||
| 18 | 24 | /** |
| 19 | 25 | * TODO: document me. |
| 20 | 26 | */ |
| 21 | 27 | public class RemoteServiceServletTestServiceImpl extends |
| 22 | 28 | RemoteServiceServletTestServiceImplBase { |
| 29 | /** | |
| 30 | * Explicitly return a 404 for the "404" URL. | |
| 31 | */ | |
| 32 | @Override | |
| 33 | protected void service(HttpServletRequest req, HttpServletResponse resp) | |
| 34 | throws ServletException, IOException { | |
| 35 | if (req.getPathInfo() != null && req.getPathInfo().endsWith("404")) { | |
| 36 | resp.sendError(HttpServletResponse.SC_NOT_FOUND, | |
| 37 | "Intentionally not found URL"); | |
| 38 | return; | |
| 39 | } | |
| 40 | super.service(req, resp); | |
| 41 | } | |
| 42 | ||
| 23 | 43 | } |
| ... | ...@@ -615,6 +615,23 @@ | |
| 615 | 615 | } |
| 616 | 616 | fail("should not be reached"); |
| 617 | 617 | } |
| 618 | ||
| 619 | /* | |
| 620 | * Issue 2770: labeled breaks in a switch statement with no default case | |
| 621 | * should not be pruned. | |
| 622 | */ | |
| 623 | outer : while (true) { | |
| 624 | switch (THREE) { | |
| 625 | case 0: | |
| 626 | case 1: | |
| 627 | case 2: | |
| 628 | case 3: | |
| 629 | break outer; | |
| 630 | case 4: | |
| 631 | case 5: | |
| 632 | break; | |
| 633 | } | |
| 634 | } | |
| 618 | 635 | } |
| 619 | 636 | |
| 620 | 637 | public void testLocalClasses() { |
| ... | ...@@ -1,13 +1,12 @@ | |
| 1 | 1 | /** Add css rules here for your application. */ |
| 2 | button { | |
| 2 | ||
| 3 | ||
| 4 | /** Example rules used by the template application (remove for your app) */ | |
| 5 | .pc-template-btn { | |
| 3 | 6 | display: block; |
| 4 | 7 | font-size: 16pt |
| 5 | 8 | } |
| 6 | 9 | |
| 7 | .widePanel { | |
| 8 | width: 100% | |
| 9 | } | |
| 10 | ||
| 11 | img { | |
| 10 | #pc-template-img { | |
| 12 | 11 | margin-top: 20px; |
| 13 | } | |
| 14 | 12 | \ No newline at end of file |
| 13 | } |
| ... | ...@@ -20,10 +20,14 @@ | |
| 20 | 20 | public void onModuleLoad() { |
| 21 | 21 | Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png"); |
| 22 | 22 | Button button = new Button("Click me"); |
| 23 | ||
| 23 | ||
| 24 | // We can add style names | |
| 25 | button.addStyleName("pc-template-btn"); | |
| 26 | // or we can set an id on a specific element for styling | |
| 27 | img.getElement().setId("pc-template-img"); | |
| 28 | ||
| 24 | 29 | VerticalPanel vPanel = new VerticalPanel(); |
| 25 | // We can add style names. | |
| 26 | vPanel.addStyleName("widePanel"); | |
| 30 | vPanel.setWidth("100%"); | |
| 27 | 31 | vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); |
| 28 | 32 | vPanel.add(img); |
| 29 | 33 | vPanel.add(button); |
| ... | ...@@ -27,6 +27,7 @@ | |
| 27 | 27 | import java.util.Map; |
| 28 | 28 | |
| 29 | 29 | import javax.servlet.ServletContext; |
| 30 | import javax.servlet.ServletException; | |
| 30 | 31 | import javax.servlet.http.HttpServlet; |
| 31 | 32 | import javax.servlet.http.HttpServletRequest; |
| 32 | 33 | import javax.servlet.http.HttpServletResponse; |
| ... | ...@@ -73,7 +74,7 @@ | |
| 73 | 74 | |
| 74 | 75 | // Read the request fully. |
| 75 | 76 | // |
| 76 | String requestPayload = RPCServletUtils.readContentAsUtf8(request); | |
| 77 | String requestPayload = readContent(request); | |
| 77 | 78 | |
| 78 | 79 | // Let subclasses see the serialized request. |
| 79 | 80 | // |
| ... | ...@@ -228,7 +229,8 @@ | |
| 228 | 229 | try { |
| 229 | 230 | if (is != null) { |
| 230 | 231 | try { |
| 231 | serializationPolicy = SerializationPolicyLoader.loadFromStream(is, null); | |
| 232 | serializationPolicy = SerializationPolicyLoader.loadFromStream(is, | |
| 233 | null); | |
| 232 | 234 | } catch (ParseException e) { |
| 233 | 235 | getServletContext().log( |
| 234 | 236 | "ERROR: Failed to parse the policy file '" |
| ... | ...@@ -319,9 +321,24 @@ | |
| 319 | 321 | } |
| 320 | 322 | |
| 321 | 323 | /** |
| 324 | * Override this method in order to control the parsing of the incoming | |
| 325 | * request. For example, you may want to bypass the check of the Content-Type | |
| 326 | * and character encoding headers in the request, as some proxies re-write the | |
| 327 | * request headers. Note that bypassing these checks may expose the servlet to | |
| 328 | * some cross-site vulnerabilities. | |
| 329 | * | |
| 330 | * @param request the incoming request | |
| 331 | * @return the content of the incoming request encoded as a string. | |
| 332 | */ | |
| 333 | protected String readContent(HttpServletRequest request) | |
| 334 | throws ServletException, IOException { | |
| 335 | return RPCServletUtils.readContentAsUtf8(request, true); | |
| 336 | } | |
| 337 | ||
| 338 | /** | |
| 322 | 339 | * Determines whether the response to a given servlet request should or should |
| 323 | 340 | * not be GZIP compressed. This method is only called in cases where the |
| 324 | * requestor accepts GZIP encoding. | |
| 341 | * requester accepts GZIP encoding. | |
| 325 | 342 | * <p> |
| 326 | 343 | * This implementation currently returns <code>true</code> if the response |
| 327 | 344 | * string's estimated byte length is longer than 256 bytes. Subclasses can |
| ... | ...@@ -56,7 +56,9 @@ | |
| 56 | 56 | public void testAlternateStatusCode() { |
| 57 | 57 | RemoteServiceServletTestServiceAsync service = getAsyncService(); |
| 58 | 58 | ((ServiceDefTarget) service).setServiceEntryPoint(GWT.getModuleBaseURL() |
| 59 | + "404"); | |
| 59 | + "servlettest/404"); | |
| 60 | ||
| 61 | delayTestFinish(TEST_DELAY); | |
| 60 | 62 | |
| 61 | 63 | service.test(new AsyncCallback<Void>() { |
| 62 | 64 | |
| ... | ...@@ -71,7 +73,7 @@ | |
| 71 | 73 | } |
| 72 | 74 | |
| 73 |