diff options
author | Sven Gothel <[email protected]> | 2014-05-11 03:03:36 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-05-11 03:03:36 +0200 |
commit | 1e53a38eb06aa8ff50660fdf7bd8570b27f27c56 (patch) | |
tree | f061dfb77af5b4c1f27da78b4dbd1881b400abc3 /test/junit/com | |
parent | 598da96b3d2ffc3e0915f73749cbafa5fa5cea90 (diff) |
Bug 923: Remove dependency of CStruct annotation processor _generation_ and generated_class_user due to Java8 issues.
Java8's annotation processor as embedded within javac does not allow
referencing not-yet existing generated classes in a class source code
which will produce these generated classes via the annotation process.
Example:
+++
import com.jogamp.gluegen.structgen.CStruct;
public class Lala {
@CStruct(name="RenderingConfig", header="TestStruct01.h")
public RenderingConfig config;
}
+++
Above example illustrates that the type 'RenderingConfig'
does not exist at time of processing the annotation.
The type will be created via the annotation process itself.
Even though we pass '-proc:only', i.e. skip java compilation,
Java8's annotation processing via javac fails in such case.
We see this as a bug within javac's annotation processing itself!
+++
This workaround splits the annotation process and using the class as
generated by the former.
To allow this to work, CStruct receives a new field 'jname'
allowing to enforce the java-name of the structure
using a dummy field type like boolean.
@CStruct(name="RenderingConfig", jname="RenderingConfig", header="TestStruct01.h")
public boolean dummy;
Further more CStruct can be annotated on the package, i.e. 'package-info.java',
avoiding the dependency problem altogether.
To support multiple header files and types,
'CStructs' has been introduced using an array of 'CStruct'.
@CStructs({@CStruct(name="RenderingConfig", header="TestStruct01.h"), @CStruct(name="Pixel", header="TestStruct02.h")})
package com.jogamp.gluegen.test.junit.structgen;
Tests:
- Build w/ Java7 and Java8
- Validated 'major version 50' (Java 6) class files (OK)
Diffstat (limited to 'test/junit/com')
-rw-r--r-- | test/junit/com/jogamp/gluegen/StructAccessorTest.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/test/junit/com/jogamp/gluegen/StructAccessorTest.java b/test/junit/com/jogamp/gluegen/StructAccessorTest.java index 4d1bffd..6c8d0e8 100644 --- a/test/junit/com/jogamp/gluegen/StructAccessorTest.java +++ b/test/junit/com/jogamp/gluegen/StructAccessorTest.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.gluegen; import java.io.File; @@ -35,15 +35,18 @@ import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.List; import java.util.Locale; + import javax.tools.Diagnostic; import javax.tools.DiagnosticCollector; import javax.tools.JavaCompiler; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; import javax.tools.ToolProvider; -import junit.framework.Assert; + import org.junit.AfterClass; +import org.junit.Assert; import org.junit.Test; + import static java.lang.System.*; import static com.jogamp.gluegen.BuildUtil.*; |