|
3 | 3 | import static com.alibaba.fastjson.util.ASMUtils.getDesc;
|
4 | 4 | import static com.alibaba.fastjson.util.ASMUtils.getType;
|
5 | 5 |
|
| 6 | +import java.io.File; |
| 7 | +import java.io.FileOutputStream; |
6 | 8 | import java.lang.reflect.Constructor;
|
7 | 9 | import java.lang.reflect.Method;
|
8 | 10 | import java.lang.reflect.Modifier;
|
|
19 | 21 | import java.util.TreeSet;
|
20 | 22 | import java.util.concurrent.atomic.AtomicLong;
|
21 | 23 |
|
| 24 | +import com.alibaba.fastjson.JSON; |
22 | 25 | import com.alibaba.fastjson.asm.ASMException;
|
23 | 26 | import com.alibaba.fastjson.asm.ClassWriter;
|
24 | 27 | import com.alibaba.fastjson.asm.FieldVisitor;
|
@@ -94,9 +97,20 @@ public ObjectDeserializer createJavaBeanDeserializer(ParserConfig config, Class<
|
94 | 97 | _deserialzeArrayMapping(cw, new Context(className, config, beanInfo, 4));
|
95 | 98 | byte[] code = cw.toByteArray();
|
96 | 99 |
|
97 |
| - // org.apache.commons.io.IOUtils.write(code, new java.io.FileOutputStream( |
98 |
| - // "/usr/alibaba/workspace-3.7/fastjson-asm/target/classes/" |
99 |
| - // + className + ".class")); |
| 100 | + if(JSON.DUMP_CLASS != null){ |
| 101 | + FileOutputStream fos=null; |
| 102 | + try { |
| 103 | + fos=new FileOutputStream(JSON.DUMP_CLASS+ File.separator |
| 104 | + + className + ".class"); |
| 105 | + fos.write(code); |
| 106 | + }catch (Exception ex){ |
| 107 | + System.err.println("FASTJSON dump class:"+className+"失败:"+ex.getMessage()); |
| 108 | + }finally { |
| 109 | + if(fos!=null){ |
| 110 | + fos.close(); |
| 111 | + } |
| 112 | + } |
| 113 | + } |
100 | 114 |
|
101 | 115 | Class<?> exampleClass = classLoader.defineClassPublic(className, code, 0, code.length);
|
102 | 116 |
|
|
0 commit comments