diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/interface-java-jaxws')
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); |