dufoli commented on a change in pull request #721:
URL: https://github.com/apache/cxf/pull/721#discussion_r537096690
##########
File path:
rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java
##########
@@ -24,78 +24,56 @@
import javax.xml.bind.JAXBElement;
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.spi.ClassGeneratorClassLoader;
import org.apache.cxf.common.util.ASMHelper;
+import org.apache.cxf.common.util.OpcodesProxy;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.databinding.WrapperHelper;
-final class WrapperHelperCompiler extends ASMHelper {
-
-
- final Class<?> wrapperType;
- final Method[] setMethods;
- final Method[] getMethods;
- final Method[] jaxbMethods;
- final Field[] fields;
- final Object objectFactory;
- final ClassWriter cw;
-
- private WrapperHelperCompiler(Class<?> wrapperType,
- Method[] setMethods,
- Method[] getMethods,
- Method[] jaxbMethods,
- Field[] fields,
- Object objectFactory) {
- this.wrapperType = wrapperType;
- this.setMethods = setMethods;
- this.getMethods = getMethods;
- this.jaxbMethods = jaxbMethods;
- this.fields = fields;
- this.objectFactory = objectFactory;
- cw = createClassWriter();
- }
-
- static WrapperHelper compileWrapperHelper(Class<?> wrapperType,
- Method[] setMethods,
- Method[] getMethods,
- Method[] jaxbMethods,
- Field[] fields,
- Object objectFactory) {
- try {
- return new WrapperHelperCompiler(wrapperType,
- setMethods,
- getMethods,
- jaxbMethods,
- fields,
- objectFactory).compile();
-
- } catch (Throwable t) {
- // Some error - probably a bad version of ASM or similar
- }
- return null;
- }
-
+public final class WrapperHelperCompiler extends ClassGeneratorClassLoader
implements WrapperHelperCreator {
+ private Class<?> wrapperType;
+ private Method[] setMethods;
+ private Method[] getMethods;
+ private Method[] jaxbMethods;
+ private Field[] fields;
+ private ASMHelper.ClassWriter cw;
+ private ASMHelper asmhelper;
+ WrapperHelperCompiler(Bus bus) {
+ super(bus);
+ }
+ public WrapperHelper compile(Class<?> wt, Method[] setters,
+ Method[] getters, Method[] jms,
+ Field[] fs, Object objectFactory) {
+ this.wrapperType = wt;
Review comment:
hmmm. it is because bus.getExtension is a singleton so always same
instance all properties must move to arg to avoid that it is modified by 2
processes. great catch.... I have check other class generator. And the only
other case is ASMHelper and no properties in it which can lead to issue
(cwClass can be shared). So it can be set and reuse without issue. The
classwriter in the other hand must been send as args... but it was not the case.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]