javassist - 添加自定义成员变量

时间:2017-01-09 00:44:12

标签: java performance javassist

我们需要根据配置为每个客户的java对象添加不同的类成员变量。所以我们使用javassist根据config在字节代码级别注入类成员。最近我们遇到了一个问题,对于一个客户,我们需要添加600多个客户特定的成员变量。我们能够将它设为600,但如果我们添加超过600,我们会得到以下错误。

org.reflections.ReflectionsException: could not get type for name com.mycompany.xxxxxxxxxx.models.impl.AccountProduct
 at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:389)
 at org.reflections.ReflectionUtils.forNames(ReflectionUtils.java:398)
 at org.reflections.Reflections.getTypesAnnotatedWith(Reflections.java:385)
 at org.reflections.Reflections.getTypesAnnotatedWith(Reflections.java:370)
 at com.mycompany.xxx.xxxxxxxxxxxxxxxx
 at com.mycompany.xxxxxxxxxxxxxxxx
 at com.mycompany.xxx.xxxxxxxxxxxxxxxx
 at io.dropwizard.Application.run(Application.java:70)
 at com.mycompany.xxx.xxxxxxxxxxxxxxxx
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at javassist.Loader.run(Loader.java:291)
 at com.mycompany.xxx.xxxxxxxxxxxxxxxx
 at com.mycompany.xxx.xxxxxxxxxxxxxxxx
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Javassist version: 3.18.2-GA
Java version: Java 1.7
AccountProduct java class (with default non-customer specific member variables):
private Account account;
private Integer accountId;
private Product product;
private Integer productId;
private Date createdAt; 
private Date updatedAt;
private Key id;

是与JVM内存相关的问题还是与javaassist相关的问题?任何人都可以知道或知道这个问题吗?任何见解?提前致谢

0 个答案:

没有答案