java - Is it possible to generate an inner class of a class to compile with an annotation processor? -
i wondering if possible generate class, via annotation processor, inner class of class compiled.
for instance, while compiling class a
, generate class a$foo
. wonder if there trick used or not. got feeling might possible generate source compiled in same byte code inner class would. and, @ compile/runtime, jvm take inner class, , allow accessing outer class private fields.
the idea behind question, not noobie question, though may more or less technical, able use private visibility modifier annotated fields dagger, butterknife, etc. private modifier allowing detect unused fields more easily, whereas package private protection hides them.
or there workaround, way best of both words ?
given use case, no.
an inner class normal java class, living in different .class file. when compiled, hidden constructor param added inner class constructor. private fields in outer class made accessible adding hidden accessor methods in outer class. of happens @ compile time.
the jvm has nothing that. if generate class "looks inner class of class", won't make outer class fields accessible.
Comments
Post a Comment