[jboss-user] [Javassist user questions] - NullPointerException at javassist.bytecode.annotation.ArrayM

theyurinator do-not-reply at jboss.com
Wed Aug 13 14:48:56 EDT 2008


Hello,

I am getting a NullPointerException somewhere beyond my control.

Here is my code

ClassPool pool = ClassPool.getDefault();
  | 		CtClass cc = pool.makeClass(class_name);
  | 		cc.stopPruning(true);
  | 		ClassFile cf = cc.getClassFile();
  | 		ConstPool cp = cf.getConstPool();
  | 		
  | 		try {
  | 			CtClass persistent_class = pool.get("net.sourceforge.pbeans.annotations.PersistentClass");
  | 			
  | 			Annotation a = new Annotation(cp, persistent_class);
  | 			a.addMemberValue("table", new StringMemberValue(class_name, cp));
  | 			a.addMemberValue("audoIncrement", new BooleanMemberValue(true, cp));
  | 			
  | 			AnnotationsAttribute attr = new AnnotationsAttribute(cp, AnnotationsAttribute.visibleTag);
  | 			attr.setAnnotation(a);
  | 			
  | 			cf.addAttribute(attr);
  | 			cf.setVersionToJava5();
  | 		} 
  | 		catch (NotFoundException e1) { e1.printStackTrace(); }

and this is the stack trace

Exception in thread "main" java.lang.NullPointerException
	at javassist.bytecode.annotation.ArrayMemberValue.write(ArrayMemberValue.java:132)
	at javassist.bytecode.annotation.Annotation.write(Annotation.java:303)
	at javassist.bytecode.AnnotationsAttribute.setAnnotations(AnnotationsAttribute.java:246)
	at javassist.bytecode.AnnotationsAttribute.setAnnotation(AnnotationsAttribute.java:265)
	at com.....PBeanGenerator.generatePBean(PBeanGenerator.java:61)
	at com.....PBeanGenerator.main(PBeanGenerator.java:145)

I have not added an ArrayMemberValue so I'm confused why I'm getting a null pointer there. Am I missing something?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170410#4170410

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4170410



More information about the jboss-user mailing list