summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-11-19 05:01:21 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-11-19 05:01:21 +0000
commit6516e97f3ba471b2afb0c075bb997106711c8908 (patch)
treeca21effd82f6f8db74ee3b11f2958a7f3e32b693 /sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org
parentee18df7f2d388d8d2e4f364bdc77acfadf81244e (diff)
Tolerate older version of ASM using reflection. There doesn't seem to be enough usage to justify an extension point.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1036741 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org')
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java20
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java22
2 files changed, 40 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java
index 6c64ad0689..05a5dc89de 100644
--- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java
@@ -20,6 +20,8 @@
package org.apache.tuscany.sca.interfacedef.java.jaxws;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -436,7 +438,23 @@ public abstract class BaseBeanGenerator implements Opcodes {
String name,
BeanProperty[] properties,
GeneratedClassLoader classLoader) {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+
+ // The reflection code here allows for toleration of older versions of ASM.
+ ClassWriter cw;
+ try {
+ Constructor<ClassWriter> c = ClassWriter.class.getConstructor(new Class[] {int.class});
+ Field f = ClassWriter.class.getField("COMPUTE_MAXS");
+ cw = c.newInstance(f.get(null));
+ } catch ( Exception ex ) {
+ try {
+ Constructor<ClassWriter> c = ClassWriter.class.getConstructor(new Class[] {boolean.class});
+ cw = c.newInstance(true);
+ } catch ( Exception ex2 ) {
+ throw new IllegalArgumentException(ex2);
+ }
+
+ }
+
byte[] byteCode = defineClass(cw, classDescriptor, classSignature, namespace, name, properties);
String className = classDescriptor.replace('/', '.');
Class<?> generated = classLoader.getGeneratedClass(className, byteCode);
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java
index 40fbefa3ed..972d179bcc 100644
--- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java
@@ -23,6 +23,8 @@ import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
@@ -72,7 +74,25 @@ public class FaultBeanGenerator extends BaseBeanGenerator {
public byte[] generate(Class<? extends Throwable> exceptionClass) {
String className = getFaultBeanName(exceptionClass);
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+
+ // The reflection code here allows for toleration of older versions of ASM.
+ ClassWriter cw;
+ try {
+ Constructor<ClassWriter> c = ClassWriter.class.getConstructor(new Class[] {int.class});
+ Field f = ClassWriter.class.getField("COMPUTE_MAXS");
+ cw = c.newInstance(f.get(null));
+ } catch ( Exception ex ) {
+ try {
+ Constructor<ClassWriter> c = ClassWriter.class.getConstructor(new Class[] {boolean.class});
+ cw = c.newInstance(true);
+ } catch ( Exception ex2 ) {
+ throw new IllegalArgumentException(ex2);
+ }
+
+ }
+
+
+
String classDescriptor = className.replace('.', '/');
String classSignature = "L" + classDescriptor + ";";
QName element = getElementName(exceptionClass);