0

jcodemodel makes it possible to add private attributes by doing something like:

JFieldVar quantity = jc.field(JMod.PRIVATE, Integer.class, "myAtt");

However, what happens instead of using a class from the JDK you are using a class that won't be on the classpath at the time you invoke field API?

All you know is the class name as a String, you don't have that class on your classpath - someone else is generating it.

More Than Five
  • 9,959
  • 21
  • 77
  • 127

1 Answers1

1

All JCodeModel will do is generate the .java file for you. When you go to compile the the generated file, and a required class is not on the classpath, you will get a compilation error. Similarly, if the class is not present at runtime, a NoClassDefFound exception will be thrown by the classloader when the class is first referenced.

johnluetke
  • 3,393
  • 1
  • 20
  • 25