There are a few XMLBeans sites that make reference to generated code taking advantage of generics (and enums) however, I can't seem to find the configuration option to set.
Sites mentioning generics in XML Beans:
http://xmlbeans.apache.org/news.html
http://wiki.apache.org/xmlbeans/V2Features
I have set the javaSource configuration to 1.5 but that still isn't causing the generated source to use generics.
(see http://mojo.codehaus.org/xmlbeans-maven-plugin/xmlbeans-mojo.html#javaSource)
Some related Stack Overflow questions:
How to get rid of generics warnings in code generated from xmlbeans-maven-plugin?
How to suppress Java warnings for specific directories or files such as generated code
#artbristol was correct, simply use the 'javaSource' tag.
Looks like we were using 'javasource' (notice case) and that was the problem. When the case issue was resolved, the target directory wasn't being cleaned properly, leaving some legacy Java 1.4 files which was the cause of the compiler warnings.
Thanks!
Related
Is there a way to configure a ClassLoader or a JVM to load annotations with CLASS retention policy, so I can access them using reflection?
This is useful for compile-time post-processing, as mentioned here.
I annotate some of my classes in order to generate an antlib.xml file automatically. I would prefer if my annotation could have CLASS retention policy, so that it does not create runtime dependencies.
javac can process source and class level annotations, with the -processor option. See javax.annotation.processing.AbstractProcessor. (Since java 1.6).
I started using it while compiling .java files. Apparently it can also be used to process CLASS annotations with .class input files. I haven't tried this because I'm using ant to compile, and ant does not seem to pass .class files to the compiler.
I have to do a full compile when I want to process all the annotations in my project.
I think you might want to have a look at this tutorial.
It explains how to create your own annotation processor and how to use it to generate code. It doesn't handle bytecode manipulation though.
He also gave a presentation available on YouTube. In case you're too lazy to read... ;-)
I have class file. It is a result of compilation. Can I know the compiler version which was used for creation of this file?
As a result I want to know something like java 1.6.0_45
No. Class file contains only format version which is not directly corresponds to compiler version.
PS: Class files mainly can be found inside jars. Jars often contains manifests. Manifest may contain compiler version.
PPS: See also here
Yes, that information is part of class file. More information here.
Edit:
I stand corrected. The compiler version is not part of the class file. I confused major and minor versions with compiler version. Still keeping the link since it provides useful information pertaining to the question.
I have little knowledge how GWT works, so can anybody help me here?
This is the full log when I use Eclipse to compile my Playn html project:
http://pastebin.com/0EXNe57a
The same error appears when I try to run the html version with Maven in Eclipse or command line. Any feedback is appreciated.
GWT is compiling your Java-Code to JavaScript and emulating the Classes and Methods you are using from the JRE. But GWT is not supporting all Classes and Methods of the JRE.
You can find a List of Supported Classes and Methods on gwtproject.org.
In your case java.util.Vectoris supported but not the methods add(float, float) and set(float, float). So you should look for an alternative.
Note: The use of java.util.Vector is not recommended - regardless of working with GWT or not.
Update: Can't remeber that there ever was a method add(float, float) in java.util.Vector. Do you use that class or do you have an own util.Vector-Implementation?
If so you should check if your gwt.xml-file is including the source-path. Already explained here.
In my source tree have Java code which is automatically generated from XSD files. This code is full of warnings which is messing other legitimate warnings. How do I exclude such folders or packages from validation?
Have read several similar questions, but those suggest to exclude folders from appropriate validator types found in Preferences. However I can't find validator for .java files.
Any help would be appreciated. Thanks!
Sasa
You need the feature 'ignore optional compiler problems' from the very latest eclipse milestone:
http://download.eclipse.org/eclipse/downloads/drops4/S-4.2M6-201203151300/eclipse-news-M6.html
Might be a workaround possible without that, like putting the auto generated files in a different project. But what you want to do is exactly the intended use of that feature.
In Eclipse, I did: Source > Clean up, and did a clean up according to these rules:
Change non static accesses to static
members using declaring type
Change indirect accesses to static
members to direct accesses (accesses
through subtypes)
Remove unused imports
Add missing '#Override' annotations
Add missing '#Deprecated' annotations
Remove unnecessary casts
Remove unnecessary '$NON-NLS$' tags
but I can't seem to compile it anymore. I get the following error:
Error preverifying class com.myapp.blackberry.Override
java/lang/NoClassDefFoundError: java/lang/annotation/Annotation
Error!: Error: preverifier failed: C:\eclipse\plugins\net.rim.ejde.componentpack6.0.0_6.0.0.29\components\bin\preverify.exe -d C:\DOCUME ...
Packaging project myapp failed (took 0.422 seconds)
When I hover over #Override, it gives me suggestion "Override cannot be resolved to a type"
I am not sure what to do at this point..
Blackberry development is built on top of j2me, which has the language features of Java 1.3. This means it doesn't support annotations. You can remove the #Override annotations and your code will work. Remember these are optional although recommended anyways.
What I do, is write //#Override instead. When/If annotations are added in the future it will be easy to do a regex replace and remove the comment marks.
Seems to be impossible:
The deal is Java ME uses version 1.4 of Java Language Specification.
You cannot use Java 5 language features.
Seems you'll have to do without annotations...