Matthew Dempsky has submitted this change and it was merged.
Change subject: Remove dependency of RequestFactory on ASM.
......................................................................
Remove dependency of RequestFactory on ASM.
This is a follow-up to r11399 which only removed half the dependencies.
Change-Id: Iec08206c60905ccce972b0400f3c1253afa01755
---
M
user/src/com/google/web/bindery/requestfactory/server/ResolverServiceLayer.java
D
user/src/com/google/web/bindery/requestfactory/server/SignatureAdapter.java
M
user/src/com/google/web/bindery/requestfactory/vm/InProcessRequestContext.java
3 files changed, 78 insertions(+), 122 deletions(-)
Approvals:
Matthew Dempsky: Looks good to me, approved
Leeroy Jenkins: Verified
diff --git
a/user/src/com/google/web/bindery/requestfactory/server/ResolverServiceLayer.java
b/user/src/com/google/web/bindery/requestfactory/server/ResolverServiceLayer.java
index 1c602bd..43b1b82 100644
---
a/user/src/com/google/web/bindery/requestfactory/server/ResolverServiceLayer.java
+++
b/user/src/com/google/web/bindery/requestfactory/server/ResolverServiceLayer.java
@@ -15,7 +15,6 @@
*/
package com.google.web.bindery.requestfactory.server;
-import com.google.gwt.dev.asm.Type;
import com.google.web.bindery.autobean.vm.impl.TypeUtils;
import com.google.web.bindery.requestfactory.shared.BaseProxy;
import com.google.web.bindery.requestfactory.shared.ProxyFor;
@@ -28,6 +27,7 @@
import com.google.web.bindery.requestfactory.vm.impl.OperationKey;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -213,41 +213,48 @@
}
private Class<?>[] getArgumentTypes(String descriptor) {
- Type[] types = Type.getArgumentTypes(descriptor);
- Class<?>[] params = new Class<?>[types.length];
- for (int i = 0, j = types.length; i < j; i++) {
- params[i] = getClass(types[i]);
+ assert descriptor.startsWith("(") && descriptor.endsWith(")V");
+ ArrayList<Class<?>> params = new ArrayList<Class<?>>();
+ for (int i = 1; i < descriptor.length() - 2; i++) {
+ switch (descriptor.charAt(i)) {
+ case 'Z':
+ params.add(boolean.class);
+ break;
+ case 'B':
+ params.add(byte.class);
+ break;
+ case 'C':
+ params.add(char.class);
+ break;
+ case 'D':
+ params.add(double.class);
+ break;
+ case 'F':
+ params.add(float.class);
+ break;
+ case 'I':
+ params.add(int.class);
+ break;
+ case 'J':
+ params.add(long.class);
+ break;
+ case 'S':
+ params.add(short.class);
+ break;
+ case 'V':
+ params.add(void.class);
+ break;
+ case 'L':
+ int end = descriptor.indexOf(';', i);
+ params.add(forName(descriptor.substring(i + 1,
end).replace('/', '.')));
+ i = end;
+ break;
+ case '[':
+ return die(null, "Unsupported Type (array) used in operation
descriptor: %s", descriptor);
+ default:
+ return die(null, "Invalid operation descriptor: %s", descriptor);
+ }
}
- return params;
- }
-
- private Class<?> getClass(Type type) {
- switch (type.getSort()) {
- case Type.BOOLEAN:
- return boolean.class;
- case Type.BYTE:
- return byte.class;
- case Type.CHAR:
- return char.class;
- case Type.DOUBLE:
- return double.class;
- case Type.FLOAT:
- return float.class;
- case Type.INT:
- return int.class;
- case Type.LONG:
- return long.class;
- case Type.OBJECT:
- return forName(type.getClassName());
- case Type.SHORT:
- return short.class;
- case Type.VOID:
- return void.class;
- case Type.ARRAY:
- return die(null, "Unsupported Type used in operation
descriptor %s", type.getDescriptor());
- default:
- // Error in this switch statement
- return die(null, "Unhandled Type: %s", type.getDescriptor());
- }
+ return params.toArray(new Class<?>[params.size()]);
}
}
diff --git
a/user/src/com/google/web/bindery/requestfactory/server/SignatureAdapter.java
b/user/src/com/google/web/bindery/requestfactory/server/SignatureAdapter.java
deleted file mode 100644
index e33cf0b..0000000
---
a/user/src/com/google/web/bindery/requestfactory/server/SignatureAdapter.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2010 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.web.bindery.requestfactory.server;
-
-import com.google.gwt.dev.asm.signature.SignatureVisitor;
-
-/**
- * An empty implementation of SignatureVisitor, used by
- * {@link RequestFactoryInterfaceValidator}. This is a copy of the dev
package's
- * EmptySignatureVisitor.
- */
-class SignatureAdapter implements SignatureVisitor {
-
- private static final SignatureAdapter ignore = new SignatureAdapter();
-
- public SignatureVisitor visitArrayType() {
- return ignore;
- }
-
- public void visitBaseType(char descriptor) {
- }
-
- public SignatureVisitor visitClassBound() {
- return ignore;
- }
-
- public void visitClassType(String name) {
- }
-
- public void visitEnd() {
- }
-
- public SignatureVisitor visitExceptionType() {
- return ignore;
- }
-
- public void visitFormalTypeParameter(String name) {
- }
-
- public void visitInnerClassType(String name) {
- }
-
- public SignatureVisitor visitInterface() {
- return ignore;
- }
-
- public SignatureVisitor visitInterfaceBound() {
- return ignore;
- }
-
- public SignatureVisitor visitParameterType() {
- return ignore;
- }
-
- public SignatureVisitor visitReturnType() {
- return ignore;
- }
-
- public SignatureVisitor visitSuperclass() {
- return ignore;
- }
-
- public void visitTypeArgument() {
- }
-
- public SignatureVisitor visitTypeArgument(char wildcard) {
- return ignore;
- }
-
- public void visitTypeVariable(String name) {
- }
-}
\ No newline at end of file
diff --git
a/user/src/com/google/web/bindery/requestfactory/vm/InProcessRequestContext.java
b/user/src/com/google/web/bindery/requestfactory/vm/InProcessRequestContext.java
index e382014..fdb3226 100644
---
a/user/src/com/google/web/bindery/requestfactory/vm/InProcessRequestContext.java
+++
b/user/src/com/google/web/bindery/requestfactory/vm/InProcessRequestContext.java
@@ -100,7 +100,7 @@
if (dialect.equals(Dialect.STANDARD)) {
StringBuilder descriptor = new StringBuilder("(");
for (Class<?> param : method.getParameterTypes()) {
-
descriptor.append(com.google.gwt.dev.asm.Type.getDescriptor(param));
+ appendDescriptor(descriptor, param);
}
// Don't care about the return type
descriptor.append(")V");
@@ -180,6 +180,40 @@
throw new RuntimeException("Should not reach here");
}
}
+
+ private void appendDescriptor(StringBuilder descriptor, Class<?>
param) {
+ // Arrays aren't actually used anywhere in RequestFactory, but it's
trivial to
+ // implement and might be useful later on.
+ while (param.isArray()) {
+ descriptor.append('[');
+ param = param.getComponentType();
+ }
+
+ if (param.isPrimitive()) {
+ if (param == Boolean.TYPE) {
+ descriptor.append('Z');
+ } else if (param == Byte.TYPE) {
+ descriptor.append('B');
+ } else if (param == Character.TYPE) {
+ descriptor.append('C');
+ } else if (param == Double.TYPE) {
+ descriptor.append('D');
+ } else if (param == Float.TYPE) {
+ descriptor.append('F');
+ } else if (param == Integer.TYPE) {
+ descriptor.append('I');
+ } else if (param == Long.TYPE) {
+ descriptor.append('J');
+ } else if (param == Short.TYPE) {
+ descriptor.append('S');
+ } else {
+ assert param == Void.TYPE;
+ descriptor.append('V');
+ }
+ } else {
+
descriptor.append('L').append(param.getName().replace('.', '/')).append(';');
+ }
+ }
}
static final Object[] NO_ARGS = new Object[0];
--
To view, visit https://gwt-review.googlesource.com/2720
To unsubscribe, visit https://gwt-review.googlesource.com/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iec08206c60905ccce972b0400f3c1253afa01755
Gerrit-PatchSet: 3
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Thomas Broyer <[email protected]>
Gerrit-Reviewer: Leeroy Jenkins <[email protected]>
Gerrit-Reviewer: Matthew Dempsky <[email protected]>
Gerrit-Reviewer: Thomas Broyer <[email protected]>
--
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
---
You received this message because you are subscribed to the Google Groups "Google Web Toolkit Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.