JDK 1.6: Annotation Processing & Compiler Hack

Hello,
I am currently using JDK 1.6.0_23
For one of the requirement, I am going with annotation processing & compiler Hack using Tools.jar available as part of JDK.
I have refered a PDF - "The Hacker's Guide to javac (PDF) by David Erni and Adrian Kuhn (2008)
" suggested from page of - http://openjdk.java.net/groups/compiler/
My requirement is below ->
Origional Source:
public void someMethod() {
}Modified Source:
public void someMethod() {
   int items = new example.Product().getItems();
} Below is my code to generate the variable declaration -
private TreeMaker make; // fetch it from somewhere
JCNewClass newProduct = make.NewClass(null, List.<JCExpression>nil(), make.Ident(names.fromString("example.Product")), List.<JCExpression>nil(), null);
JCFieldAccess fieldAccess = make.Select(newProduct, names.fromString("getItems"));
JCMethodInvocation getTimeMethodInvocation = make.Apply(List.<JCExpression>nil(), fieldAccess, List.<JCExpression>nil());
expression = getTimeMethodInvocation;
JCVariableDecl itemsDeclaration = make.VarDef(modifiers,name,varType,expression);
System.out.println(itemsDeclaration); // this prints int items = new example.Product().getItems(); This itemsDeclaration, I am adding to a List<JCStatement> of JCBlock of JCMethodDecl.
However modified code does not compile :(
If I make below changes - Modified does compile
1)
JCNewClass newProduct = make.NewClass(null, List.<JCExpression>nil(), make.Ident(names.fromString("Product")), List.<JCExpression>nil(), null);Product insteadof example.Product
2) Add belwo statement in the origional source code
import examle.Product; What exactly am I missing here ???
The AST tree is diffcult to understand with minimum documentation & without much help on the interent.
I hope this is correct forum, for my query.
It will be a great help.
Regards,
Vikas Parikh

Hello,
I couldn't contact them, as the white papaer didn't conatin any email address / contact info.
I have investigated myself on this & would like to share with you guys, so that any other developer
do not have to invest precious time like I have done.
To create a New Class, you require a JCExpression.
Below would work, if class already has imported Product class.
make.Ident(names.fromString("Product"))However, if class has not imported the Product class, then there are 2 options -
1) Create a Ident</pre> from <pre>Symbol (ClassSymbol)
2) Create a JCField</pre> from <pre>NameI used a later approach.
Regards,
Vikas Parikh
Edited by: 996153 on Mar 31, 2013 11:04 PM

Similar Messages

  • Compile time Annotation Processing

    Is it possible to access the source of the file being analysed at compile time?
    Thanks

    Milesy wrote:
    Is it possible to access the source of the file being analysed at compile time?If you are naughty, you can try to find the file being processed and read it directly, but that is not supported.
    You can use the javac-specific tree API (http://java.sun.com/javase/6/docs/jdk/api/javac/tree/index.html) to map from a javax.lang.model.Element to a AST representing the source for a method or constructor.
    If you want the source for the purposes of modifying it, the annotation processing API is read-only, but much of the effect of mutating the source can be achieved by generating subclasses or the superclass of the class in question. Check the forum archives for details.

  • Annotation processing using JDK 1.6 and Apache Ant

    Hello,
    I am trying to run my annotation processor using ant.
    I already built the processor, the javax.annotation.processor.Processor file is in the correct place with the correct content.
    The jar with the processor is in the classpath (i can see it in ant -v), but it does not process my classes. in fact, i get the warning:
    warning: Annotation processing without compilation requested but no processors were found.Do i have to specify -processor or -processorpath or can i just leave it to the default classpath scanning?
    I think everything is in the correct place, because when i compile with maven instead of ant, specifying the processor, it runs nicely. My pom contains:
                   <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                             <source>1.6</source>
                             <target>1.6</target>
                             <compilerArguments>
                                  <processor>br.com.sonner.infra.seguranca.SegurancaAnnotationProcessor</processor>
                             </compilerArguments>
                        </configuration>
                   </plugin>i am using jdk 1.0.6_02 and ant 1.7.0.
    Can anyone help me find out what am i doing wrong?

    Julio.Faerman wrote:
    Hello,
    I am trying to run my annotation processor using ant.
    I already built the processor, the javax.annotation.processor.Processor file is in the correct place with the correct content.
    The jar with the processor is in the classpath (i can see it in ant -v), but it does not process my classes. in fact, i get the warning:
    warning: Annotation processing without compilation requested but no processors were found.Do i have to specify -processor or -processorpath or can i just leave it to the default classpath scanning?When -processor is not given, a service loader is used to find the annotation processors (if any). In addition to the class files of the process, to allow your processor to be found as a service, make sure you've also provided the needed META-INF data in the jar file. The general service file format is described in
    http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html
    That said, I'd recommend setting an explicit processor path separate from your general classpath.

  • Is it possible to stop compiling process in annotations processing?

    Hi all.
    I'm doing annotations processing with javac.
    Is it possible to stop compilation if an error occurs during annotations processing?
    Thank you!

    francadaval wrote:
    Hi all.
    I'm doing annotations processing with javac.
    Is it possible to stop compilation if an error occurs during annotations processing?If you raise an error with the Messager:
    http://java.sun.com/javase/6/docs/api/javax/annotation/processing/Messager.html
    no class files will be generated. This is the recommended way to start winding things down; from the Processor class:
    "If a processor throws an uncaught exception, the tool may cease other active annotation processors. If a processor raises an error, the current round will run to completion and the subsequent round will indicate an error was raised. Since annotation processors are run in a cooperative environment, a processor should throw an uncaught exception only in situations where no error recovery or reporting is feasible."

  • New com.sun.mirror.* packages - annotation processing

    Hello,
    i would like to use annotation processing tool (APT), but there is much to learn yet.
    So, please help me.
    Let�s have an annotation that can be apllied to all code declarations (source code entities).I want to process some *.java files (their proper source code) via APT.From this code i wanna gain (in any way) those declarations (classes, ifaces, methods, constructors, etc.) that are annotated just with the only one annotation that i have.
    i was already going through the API, but not well-understood.
    As written, i created AnnotationProcessorFactory (just my annotation should be processed by this factory) with an appropriate AnnotationProcessor.
    I�ve already done some steps to succeed, but you know, that�s not that i want
    Of course, all is performed in build-time, after i call apt command with the option factory with the appropriate factory class
    Thank you a lot

    Hi,
    I am new to this forum and also just started
    working on apt can u plz tell me where do i get
    com.sun.mirror package and its sub-packages
    hanksIf you can use JDK 6, I strongly recommend using the standardized annotation processioning in javac and the packages javax.annotation.processing and javax.lang.model..* instead of apt and its com.sun.mirror.* API. To get started, take a look at
    sample/javac/processing/src/CheckNameProcessor.java
    under the JDK 6 install directory.
    If you just need to compile against the apt API, it is found in the tools.jar file in Sun's JDK; see http://java.sun.com/j2se/1.5.0/docs/guide/apt/GettingStarted.html
    You can find a jar file with just the API definition from https://aptmirrorapi.dev.java.net/.

  • Is annotation processing the same for Java 5 and Java 6?

    I've been trying to use a package of annotations and processors that was evidently originally designed to be used with "apt" and Java 5. When I try to use this stuff with Java 6 I was assuming that, since the Java 6 javac handles annotations, I could just use javac instead of apt - but it doesn't work; the annotation processors don't appear to be getting executed. It looks like I have to use apt for the Java 6 build after all.
    The question is, did the annotation mechanism change significantly between 5 and 6 that would account for this? Is there a way to adapt an annotation package (i.e. annotation classes and processors) that works with 5 so that it will work with 6 using javac instead of apt (or alternatively, is there a way to tell javac to process the older annotations in the same way that apt would)?

    PeteFord wrote:
    I've been trying to use a package of annotations and processors that was evidently originally designed to be used with "apt" and Java 5. When I try to use this stuff with Java 6 I was assuming that, since the Java 6 javac handles annotations, I could just use javac instead of apt - but it doesn't work; the annotation processors don't appear to be getting executed. It looks like I have to use apt for the Java 6 build after all.
    The question is, did the annotation mechanism change significantly between 5 and 6 that would account for this? Is there a way to adapt an annotation package (i.e. annotation classes and processors) that works with 5 so that it will work with 6 using javac instead of apt (or alternatively, is there a way to tell javac to process the older annotations in the same way that apt would)?If you have apt annotation processors, you can use the apt command in JDK 6.
    However, the javac in JDK 6 support standardized JSR 269 annotation processing; see the javax.annotation.processing package. JSR 269 annotation processing is significantly redesigned and improved based on experiences with apt.
    It would be "a small matter of programming" to port an apt annotation processor to JSR 269.
    Using apt in JDK 6, you can also run both apt and javac processors from a single command line invocation.

  • Code Generation Using Annotation Processing

    I'm trying to figure out how to do something like thus:
    Given this source file with the following custom annotation:
    @Composite(interfaces=Mammal.class)
    public class Dog implements IComposite
    };I want to create an annotation processor that inserts a data member, implementation into the constructor, and a public method into this class:
    @Composite(interfaces=Mammal.class)
    public class Dog implements IComposite
        IComponent[] m_inner_objects;
        public Dog()
            m_inner_objects = new IComponent[1];
            m_inner_objects[0] = Mammal.compose(this);
        public IComponent getComponent(Class<?> inInterface)
            if(inInterface == Mammal.class)
               return m_inner_objects[0];
            return null;
    };Are all three tasks possible? Are any of the three tasks possible? If yes to any of my questions how would I go about this. I've gotten just past the 'hello world' state in writing a custom annotation processor so I just need the more advanced knowledge of how to actually affect the code once I'm actively processing it.
    cheers,

    brucechapman wrote:
    sednivo wrote:
    I can get the CompilationUnitTree. Yes
    Then I can modify it with Compiler Tree API.Really?
    Where is a pitfall in my train of thought?The Tree API is an immutable API, you can look, but not modify.Here is example of modifying compiler tree.
    http://svntrac.hanhuy.com/repo/browser/hanhuy/trunk/panno/src/com/hanhuy/panno/processing/PropertyProcessor.java
    Also, the javax.annotation.processing.Filer will not allow you to overwrite an existing compilation unit, and you must use the Filer if you wish a generated class to be compiled in the next round.I don't use Filer class. Method writeCompilationUnit that I've wrote works well for existed files.
    There is a fundamental principle of java that the same program always has the same meaning. See the 3rd paragraph of the Preface to the first edition of the Java Language Spec . >This is the reason why you can't modify existing source code.We can mark generated methods in a class with @Generated annotation.

  • Javax.annotation.processing.Processor not recognized

    Hi,
    I'm currently experimenting with the javax.annotation.processing API. Thus I created a simple Annotation and a related simple processor.
    Another sample program uses the annotation. When compiling this program everything works fine as long as I specify the processor class
    on the command line. But when I try to simply use a javax.annotation.processing.Processor file, the compiler doesn't seem to find the processor.
    What am I doing wrong?
    Here come the details:
    I use Java6 and the sun java compiler javac.
    The annotation and processor class are packed into a JAR file together with the javax...Processor file. The JAR looks like this:
         hello/HelloProcessor.class
         hello/annotations/Hello.class
         META-INF/services/javax.annotation.processing.Processor
         META-INF/MANIFEST.MF     The javax.annotation.processing.Processor file is UTF-8 encoded and contains a single line:
         hello.HelloProcessorwithout the leading spaces.
    My processor looks like this:
         @SupportedAnnotationTypes (value = {"hello.annotations.Hello"})
         public class HelloProcessor extends AbstractProcessor {
             private int mCounter = 0;
             /* (non-Javadoc)
              * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)
             @Override
             public boolean process(Set<? extends TypeElement> aAnnotations, RoundEnvironment aRoundEnv) {
              Messager vMessager = processingEnv.getMessager();
              vMessager.printMessage(Kind.NOTE, "Runde " + ++mCounter);
              vMessager.printMessage(Kind.NOTE, "Hello World!");
              return false;
         }The following call works...
         javac -processor hello.HelloProcessor -d bin -sourcepath src -cp lib/helloap.jar src/hello/examples/SimpleClass.javaand leads to the following output:
         warning: No SupportedSourceVersion annotation found on hello.HelloProcessor, returning RELEASE_6.
         Note: Runde 1
         Note: Hello World!
         Note: Runde 2
         Note: Hello World!          And this call does not seem to work:
         javac -d bin -sourcepath src -cp lib/helloap.jar src/hello/examples/SimpleClass.javaas it does not produce any output.
    And when I try to configure the processor in eclipse, the processor simply is not found, when I define the helloap.jar on the factory path.
    I'd be happy about every hint.
    Greetings
    yawah

    It sounds like your META-INF/services information is bad.
    Outside of javac, I suggest trying to find your processor from its jar file using java.util.ServiceLoader.
    I'd also try making sure your META-INF/services file ends with a newline character rather than just ends.

  • Annotation process tools build performance issue

    Annotation process tools is taking 85 minutes to compile page flow files. Is there any suggestion to improve performance.

    As you probably already have gathered, you have different execution plans in the two environments. There could be different reason why this happens, for instance different profiles of the data. But more likely it is due to that in the slow environment, the
    plan was built from some atypical set of input parameters, which causes a performance issue when the procedure is run in a normal fashion.
    When you say that the query has a lot of isnull and convert functions I get a little worried. If it is only in the SELECT list, it's not evil, but if functions are used in the WHERE or ON clauses, the query might benefit from a review, and possibly also
    the data model. But this is pure speculation at this point.
    I would suggest more than one course of action. As a short-term solution, you run UPDATE STATISTICS WITH FULLSCAN on all tables involved, as out-dated statistics can also be explanation for why you got a bad plan. New statistics should trigger a recompilation.
    But even if this resolves the issue, it may not be feasible in the long run, because the events indicate that the query is sensitive to something and the bad plan could come back any day. For this reason, it might be a good idea to make sure that the query
    does include inappropriate constructs, and you also need to review that there are good indexes in place.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Problem by BPEL process compilation with JDeveloper

    Hi,
    I don't quite know whether my problem is in the JDeveloper forum or Oracle Process Manager one.
    I am currently trying to execute a process, with dynamic invocation and dynamic management capabilities, but I won't go into technical details. In the WSDL Definition for the process I have defined 2 partnerLinkTypes - one for the standard synchronous request/response (receive-reply) and one for my management port (asynchronous receive).
    The end of the WSDL Definition is as follows:
    <portType name="ConfigurationPort">
    <operation name="ConfigurationChanged">
    <input message="client:ConfigMessage"/>
    </operation>
    </portType>
    <portType name="DynamicDBServiceProcess">
    <operation name="process">
    <input message="client:DynamicDBServiceProcessRequestMessage"/>
    <output message="client:DynamicDBServiceProcessResponseMessage"/>
    </operation>
    </portType>
    <plnk:partnerLinkType name="DynamicDBServiceProcess">
    <plnk:role name="DynamicDBServiceProcessProvider">
    <plnk:portType name="client:DynamicDBServiceProcess"/>
    </plnk:role>
    </plnk:partnerLinkType>
    <plnk:partnerLinkType name="ConfigPartner">
    <plnk:role name="Reconfigure">
    <plnk:portType name="client:ConfigurationPort"/>
    </plnk:role>
    <plnk:role name="ReconfigureResponse">
    <plnk:portType name="client:ConfigurationPort"/>
    </plnk:role>
    </plnk:partnerLinkType>
    The JDeveloper BPEL compiler is supposed to generate the binding and service tags for my abstract portTypes, but the binding and service for my ConfigurationPort are somehow wrong generated:
    <binding name="DynamicDBServiceProcessBinding" type="tns:DynamicDBServiceProcess">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="process">
    <soap:operation style="document" soapAction="process"/>
    <input>
    <soap:body use="literal"/>
    </input>
    <output>
    <soap:body use="literal"/>
    </output>
    </operation>
    </binding>
    <binding name="ConfigurationPortBinding" type="tns:ConfigurationPort">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="ConfigurationChanged">
    <soap:operation style="document" soapAction="ConfigurationChanged"/>
    <input>
    <soap:header message="tns:WSARelatesToHeader" part="RelatesTo" use="literal" encodingStyle=""/>
    <soap:body use="literal"/>
    </input>
    <output>
    <soap:body use="literal"/>
    </output>
    </operation>
    </binding>
    <service name="DynamicDBServiceProcess">
    <port name="DynamicDBServiceProcessPort" binding="tns:DynamicDBServiceProcessBinding">
    <soap:address location="http://I71NB60:9700/orabpel/default/DynamicDBServiceProcess/2.4"/>
    </port>
    </service>
    <service name="ConfigurationPortService">
    <port name="ConfigurationPortPort" binding="tns:ConfigurationPortBinding">
    <soap:address location="http://set.by.caller"/>
    </port>
    </service>
    I tried to find some configuration property for the project in order to properly modify the generation of my soap:address location (it surely isn't http://set.by.caller/). Nevertheless the process compiles fine and is successfully deployed, but at runtime an exception is generated because of "java.sql.SQLException: [POL-3221] Null-Schl?ssel in prim?rem Index" (trying to insert a NULL key in the primary Index). Has anyone know how to tune my project (or compiler) settings in order to generate a proper binding and service?
    Best regards,
    Genadi Genov

    Try posting on the BPEL forum BPEL

  • BPM CBS - Exception during process compilation

    Hi Experts,
    I am developing a BPM process using SAP NWDS 7.2 and a remote NWDI track.
    I have the following issue: When I edit my process, I create an activity for submit this changes. Later I try to check-in the activity and everything is okay, but when I try to activate it, the build finished with Errors. This is very unusual because locally I can to build this project without errors, and I can to deploy it directly to the Server without errors.
    The summary of error in CBS Build Log is the following:
    PF.DefaultDataArea:DCs/******.***/compose/pre/pr/pm/_comp/src/bpmn/procesoprecontractual mdn.bpmn#E0A5ADB5FB36314E74BD11E09935002564647A9C (MRI), CompilerType: BPMN2CSVCOMPILER
    Compiling process 'Proceso Precontractual' ...
    Error: "BPM.bp.00006" BC-BMT-BPM-SRV com.sap.tc.glx.BpemTask execute()- Exception during process compilation, compilerType:
    BPMN2CSVCOMPILERcaused by java.lang.IllegalArgumentException:
    com.sap.sdo.impl.xml.XmlParseException: Invalid byte 2 of 4-byte UTF-8
    sequence.
    Ant build finished with ERRORS
    java.lang.IllegalArgumentException:
    com.sap.sdo.impl.xml.XmlParseException: Invalid byte 2 of 4-byte UTF-8
    sequence.
    Error: Build stopped due to an error: java.lang.IllegalArgumentException:
    com.sap.sdo.impl.xml.XmlParseException: Invalid byte 2 of 4-byte UTF-8
    sequence.
    MOIN forced shutdown initiated.
    I checked the file "DCs/*****.**/compose/pre/pr/pm/_comp/src/bpmn/procesoprecontractual mdn.bpmn" and it doesnu2019t have any invalid characters like latin characters "á,é,í,ó,ú,ñ". I donu2019t know what other kind of characters are invalid or what is the exactly error.
    Thanks,
    Julian Andres Sanchez

    Hello,
    This issue is resolved now.
    The problem was with the file system space on the Unix server(on which portal is installed).
    The server administrators and the Basis team extended the disk space and issue got resolved.
    Thanks for all your inputs.
    Sonali.

  • Annotation-Processing Using Custom ClassLoader Fails

    Hi,
    I have the following problem concerning annotations.
    I am using Jaxb2 to marshal some classes and Jaxb relies heavily on processing annotation information contained in them.
    If I put the Jaxb JAR's directly in the classpath everything works fine.
    However, if I use a custom URLClassLoader to load all the Jaxb-related classes the annotation processing fails thus making Jaxb believe that the objects can't be marshaled.
    Note that the classes to marshal containing the annotations to read are loaded with a different ClassLoader which is higher in the hierarchy.
    I tracked down the problems to the class RuntimeInlineAnnotationReader of the Jaxb API which simply calls Class.getAnnotion(..).
    When searching for this bug I also found the bug report 5015623 which relates to this problem. But it is rather outdated, so I hope that there are some better solutions than just ignoring it.
    I wouldn't like having the Jaxb JARs on the global classpath 'cause they are used in only one class out of 100 and thats not worth the possible conflicts with other 3rd party libs.
    Best regards,
    beebop

    No problem, I will give you some details about my architecture.
    First of all I encapsulated the code which uses the Jaxb-API in one class, say Foo, which implements the interface FooInterface.
    Secondly I load the Foo class in another class, Bar, using my derivation of URLClassLoader, called MyClassLoader. Then I use the interface to marshal an object gen of type GenClass where GenClass was generated using xjc:
    class Bar {
      void method(URL[] urls, GenClass gen) {
        ClassLoader parent = Bar.class.getClassLoader();
        ClassLoader myCL = new MyClassLoader(urls,parent);
        Class clazz = myCL.loadClass("Foo");
        FooInterface foo = (FooInterface)clazz.newInstance();
        foo.marshal(gen);
    }So my class loader will be a child of the current class loader. The delegation model of class loading is reversed in MyClassLoader so that first the urls will be checked and then, if the class was not found, the parent class loader.
    Note that GenClass and its ObjectFactory which acutally contain the annotations Jaxb needs will be loaded by the current class loader, not my own. All classes of the Jaxb-API will be loaded by MyClassLoader. If I try to marshal gen, the annotations of the ObjectFactory corresponding to GenClass won't be readable causing the Class.getAnnotation(...) method called in the class RuntimeInlineAnnotationReader to return null.
    If I don't use my own class loader, say
    FooInterface foo = new Foo();everything works fine and the annotations of the ObjectFactory are loaded correctly.
    I observed the different behaviour by stepping through the classes and methods around JaxbContext.newInstance(...).
    MyClassLoader is not that different from URLClassLoader, only the loadClass method is overridden to change the delegation behaviour. Thats why I suspect an error in the annotations framework and not in my class loader but I may be mistaken.
    Best regards,
    beebop

  • Annotation Processing Error - Run vs Debug

    Hello,
    I'm trying to run the Converter Example (Chapter 21 of the Sun's JavaEE 5 Tutorial) with a difference: I've deleted the Enterprise application ("Converter") and I'm using the packages alone: one for the EJB (Converter-ejb) and the second is the App Client (Converter-app-client). No modifications yet. Both use simple (non decorated) annotations @EJB (in the app-client) and @Stateless and @Remote (in the ejb).
    All deployed OK. If you run the Converter-app-client in the Netbeans (version 5.5 - "run main project" command - F6) the
    AppServer (SunJavaSystemAppServer 9.01) issues the folloing exceptions:
    "Class [ Lcom/sun/tutorial/javaee/ejb/ConverterRemote; ] not found. Error while loading [ class com.sun.tutorial.javaee.ejb.ConverterClient ]"
    "Error in annotation processing: java.lang.NoClassDefFoundError: Lcom/sun/tutorial/javaee/ejb/ConverterRemote;"
    The "Converter-app-client (run)" tab window shows the following exception:
    "java.lang.NullPointerException"
    If you run with "Debug Main Project (F5)", the server issues the same errors, but runs the program ok and you can see it's
    results in the "Converter-app-client (debug)" tab window.
    So:
    What's the difference? Why it runs with "debug" and not in "run"?
    After reading many articles, forum, etc it seems to me that It shouldn't issue any "Error in annotation processing".I've
    tried to use the annotation's (name="xxx") and (mappedName="xxx") with no success. Tried also using the files "sun-*.xml" as instructed in the Glassfish EJB FAQ's.
    Any help will be very appreciated.
    Thanks in advance,
    Marcos

    It seem that it's an Netbean 5.5 error.
    This example application (very similar) runs ok (outside Netbeans)
    https://glassfish.dev.java.net/javaee5/ejb/examples/Sless.html
    Comparing the apps, it seems that Netbeans is not packing the AppClient correctly, dropping the remote interfaces of the referred beans.

  • Metadata annotations processing?

    When are metadata annotations processing? Just when the applications starts or during the runtime also?

    why do you need to know how this happens? Because I want to know how the matedata mapping process goes?
    I want to know when for some persistence class appropriate object ( or group of objects) that is responsible for making mapping is created (object that e.g moves attributes value from and to database etc.). Is this object created only once for persistence class or e.g each time when some persistence operation is done?
    could You explain me this?

  • Annotation-caused compiler crash

    Hi,
    When attempting to build against a class that uses runtime annotations, javac is crashing with:
    An exception has occurred in the compiler (1.6.0-rc). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
    com.sun.tools.javac.code.Symbol$CompletionFailure: class file for test.annotation.TestAnnotation not found
    The test case that generates this error can be found at:
    http://www.cjtucker.com/annotation-bug.tgz
    Synopsis:
    Attempting to build against a class that contains a runtime annotation requires the definition of the annotation to be available to the compiler. If the definition is not available, the compiler crashes.
    Test case:
    The test case attempts to build three classes in three separate packages: a simple RUNTIME scoped annotation, a "core" class, and a "ui" class that builds against the core class. The "ui" class neither knows nor cares about the annotated properties of the "core" class. The annotation class is build in isolation; the core class is built only against the annotation class; the ui class is built only against the core class.
    The test case tarball contains the necessary .java files and directory structure for compilation. The compilation commands are contained in compile.sh.
    The crash can be avoided by including the annotation class in the classpath when building the ui component. The crash has been reproduced in 1.5.0_04, 1.5.0_05, and 1.6.0b61. Other JDKs have not been tested. The crash occurs with both RUNTIME and CLASS scoped annotations, though not with SOURCE scope (as expected: the compiler is correctly stripping annotations in that case). The crash does not occur if the annotation does not take parameters (i.e. is an empty "marker" annotation).
    This raises some additional questions I'd be interested in hearing comment on. What is the expected behavior here? I would expect the annotation class should not be required as a dependency, in the same way I'm not expected to declare a dependency on every class used by a class I interact with. This behavior with annotations seems to breach encapsulation (for example, a client would have to know that my libraries happened to be using a Hibernate persistence layer whether or not this is of interest to them). Perhaps one of the Java gurus here could shed some further light on this?
    Cheers,
    Chris Tucker

    Hi,
    I know this is an old post but I am having the exact same problem with 1.6.0_11 and have not been able to find a solution.
    Any assistance would be much appreciated.
    Thanks.

Maybe you are looking for

  • Export all data of selected line in search help to fields in table control

    I've created a search help which will export 4 fields. These 4 fields should be populated to the corresponding fields in TABLE CONTROL. However, in my program, only the first column is populated and the others are blank. How to solve this problem? Do

  • Problem in OKS_CONTRACTS_PUB

    Hi, I am making a conversion for contracts. Here is my code r_k_header_rec.contract_number := v_contract_number; --M203125v3 r_k_header_rec.start_date := to_date (v_contract_header.start_date,'MM/DD/YYYY'); r_k_header_rec.end_date := to_date(v_contra

  • Installing Windows 7 on 4-1115dx

    When I get to the custom installation screen while installing Windows 7 there are no drives to be found and I cannot find a driver to load that would allow it to work.  Any Ideas? This question was solved. View Solution.

  • Byte Serving for pdf

    Hello, I make a servlet that sends pdf with byte serving. I have no problems with Windows Clients but with Macintosh clients (Explorer, Netscape 7 works) acrobat waits like expecting some data. Any idea if I must use some special header or do you hav

  • Partition by list (substr(col_name,1,4)) possible?

    Hi, Can we partition table by list based on function not just column? partition by list (substr(column_name,1,4)) -Thanks Regards, Chan.