Java runtime retention annotations - annotation class required at compile time but not at runtime? -


i trying figure out exact effects in regards compile time , runtime classpaths of class annotated runtime level retention annotation, example: @javax.inject.named. understanding far:

  1. the javax.inject.named class must present @ compile time on classpath.
  2. this compiled bytecode meta-data , can obtained @ runtime via reflections api , processed accordingly; however, class not need exist on runtime classpath.

thus, if compile jar java class annotated @javax.inject.named, compiled jar file can run both in container (ie jboss) , in plain old jvm launched command line (with no additional classpath entires). however, if make source code available project compiled along using javac (and no additional classpath entires), no longer compile correctly? if assumption correct, seems little limiting if need share both compiled binaries , source files amongst projects may or may not running in container (ie jboss).

if case, need create wrapper object (annotated @javax.inject.named) delegates inner, non-annotated object? option disable annotation processing @ compile time? see http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javac.html#processing

you need annotation present in compile classpath compile source files using annotation. don't need in classpath compile class using compiled class b using annotation.

many open-source libraries (like guava or dbsetup example) use javax.annotation or findbugs annotations example, don't need have annotations in classpath compile (and run) own source code relying on these libraries.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -