Update to build and run with jdk 11:

* Building with jdk 11 adapted from similar commit for Linux here:
https://github.com/MeFisto94/lwjgl/commit/72e97f53f7d256bc90e397e946054fcbe764c203

Input, testing and ok thfr@
This commit is contained in:
kurt
2025-12-24 15:40:31 +00:00
parent b78ec18cf1
commit f9fbb3adb6
13 changed files with 289 additions and 7 deletions
+6 -2
View File
@@ -6,7 +6,7 @@ GH_PROJECT= lwjgl
GH_TAGNAME= ${GH_PROJECT}${V}
DISTNAME= lwjgl${V}
PKGNAME= lwjgl-${V}
REVISION= 5
REVISION= 6
.if ${MACHINE_ARCH} == "i386"
M_ARCH= ""
@@ -27,7 +27,7 @@ PERMIT_PACKAGE= Yes
WANTLIB += GL X11 Xcursor Xext Xrandr Xxf86vm m pthread
MODULES= java
MODJAVA_VER= 1.8
MODJAVA_VER= 11
MODJAVA_BUILD= ant
BUILD_DEPENDS= audio/openal
@@ -36,6 +36,10 @@ NO_TEST= Yes
SUBST_VARS+= M_ARCH
FIX_CRLF_FILES= platform_build/build-generator.xml \
src/native/common/org_lwjgl_BufferUtils.c \
src/native/common/org_lwjgl_opencl_CallbackUtil.c
pre-configure:
perl -pi -e 's,/usr/X11R6,${X11BASE},g' \
${WRKSRC}/platform_build/bsd_ant/build.xml
+68
View File
@@ -0,0 +1,68 @@
Build with jdk-11
Index: build.xml
--- build.xml.orig
+++ build.xml
@@ -295,6 +295,7 @@
<!-- Generates the native headers from source files -->
<target name="headers" description="invokes javah on java classes" depends="compile">
+ <!--
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux">
<class name="org.lwjgl.LinuxSysImplementation" />
<class name="org.lwjgl.opengl.LinuxEvent" />
@@ -371,6 +372,7 @@
<class name="org.lwjgl.opengles.GLContext"/>
<class name="org.lwjgl.opengles.CallbackUtil"/>
</javah>
+ -->
</target>
<target name="touch-version">
@@ -401,21 +403,21 @@
</tokenfilter>
</filterchain>
</loadfile>
- <loadfile srcfile="${lwjgl.src.native}/windows/org_lwjgl_WindowsSysImplementation.h" property="lwjgl.native.windows.version">
+ <loadfile srcfile="${lwjgl.src.native}/org_lwjgl_WindowsSysImplementation.h" property="lwjgl.native.windows.version">
<filterchain>
<tokenfilter>
<containsstring contains="#define org_lwjgl_WindowsSysImplementation_JNI_VERSION"/>
</tokenfilter>
</filterchain>
</loadfile>
- <loadfile srcfile="${lwjgl.src.native}/linux/org_lwjgl_LinuxSysImplementation.h" property="lwjgl.native.linux.version">
+ <loadfile srcfile="${lwjgl.src.native}/org_lwjgl_LinuxSysImplementation.h" property="lwjgl.native.linux.version">
<filterchain>
<tokenfilter>
<containsstring contains="#define org_lwjgl_LinuxSysImplementation_JNI_VERSION"/>
</tokenfilter>
</filterchain>
</loadfile>
- <loadfile srcfile="${lwjgl.src.native}/macosx/org_lwjgl_MacOSXSysImplementation.h" property="lwjgl.native.macosx.version">
+ <loadfile srcfile="${lwjgl.src.native}/org_lwjgl_MacOSXSysImplementation.h" property="lwjgl.native.macosx.version">
<filterchain>
<tokenfilter>
<containsstring contains="#define org_lwjgl_MacOSXSysImplementation_JNI_VERSION"/>
@@ -462,7 +464,9 @@
<!-- Compiles the Java source code -->
<target name="compile" description="Compiles the java source code" depends="-initialize">
- <javac debug="yes" destdir="${lwjgl.bin}" source="1.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar:${lwjgl.lib}/asm-debug-all.jar" taskname="core">
+ <javac debug="yes" destdir="${lwjgl.bin}" source="1.6" target="1.6"
+ classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar:${lwjgl.lib}/asm-debug-all.jar"
+ taskname="core" nativeHeaderDir="${lwjgl.src.native}">
<!--<compilerarg value="-Xlint:unchecked"/>-->
<src path="${lwjgl.src}/java/"/>
<src path="${lwjgl.src}/generated/"/>
@@ -475,8 +479,8 @@
<include name="org/lwjgl/util/**"/>
<exclude name="org/lwjgl/util/generator/**"/>
</javac>
- <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/test/**" source="1.5" target="1.5" taskname="test" />
- <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/examples/**" source="1.5" target="1.5" taskname="examples" />
+ <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/test/**" source="1.6" target="1.6" taskname="test" />
+ <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/examples/**" source="1.6" target="1.6" taskname="examples" />
</target>
<target name="compile_native" depends="-initialize, headers, touch-version, version-mismatch" description="Compiles the native files">
@@ -1,18 +1,32 @@
Use os.arch on 64 bit builds.
Build with jdk-11
Build only 32 bit on i386 and 64bit only otherwise
Index: platform_build/bsd_ant/build.xml
--- platform_build/bsd_ant/build.xml.orig
+++ platform_build/bsd_ant/build.xml
@@ -5,7 +5,7 @@
@@ -4,8 +4,9 @@
<property name="native" location="../../src/native"/>
<property name="libname32" value="liblwjgl.so"/>
<property name="libname64" value="liblwjgl64.so"/>
<property name="libs32" value="-L/usr/X11R6/lib -L/usr/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -pthread -L${java.home}/lib/i386 -ljawt" />
- <property name="libs32" value="-L/usr/X11R6/lib -L/usr/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -pthread -L${java.home}/lib/i386 -ljawt" />
- <property name="libs64" value="-L/usr/X11R6/lib -L/usr/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -pthread -L${java.home}/lib/amd64 -ljawt" />
+ <property name="libs64" value="-L/usr/X11R6/lib -L/usr/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -pthread -L${java.home}/lib/${os.arch} -ljawt" />
+ <!-- After JDK 8 (at least on JDK 11), the architecture isn't part of the lib folder anymore -->
+ <property name="libs32" value="-L/usr/X11R6/lib -L/usr/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -pthread -L${java.home}/lib -ljawt" />
+ <property name="libs64" value="-L/usr/X11R6/lib -L/usr/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -pthread -L${java.home}/lib -ljawt" />
<property name="cflags32" value="-O2 -Wall -c -fPIC -std=c99 -Wunused"/>
<target name="clean">
@@ -67,7 +67,9 @@
@@ -64,10 +65,19 @@
</and>
</condition>
+ <condition property="build.32bit.only">
+ <and>
+ <os name="OpenBSD"/>
+ <equals arg1="${hwplatform}" arg2="i386"/>
+ </and>
+ </condition>
+
<condition property="build.64bit.only">
<and>
<os name="OpenBSD"/>
@@ -23,3 +37,19 @@ Index: platform_build/bsd_ant/build.xml
</and>
</condition>
@@ -87,6 +97,7 @@
<arg value="-I${java.home}/../include/openbsd"/>
<arg value="-I/usr/local/include"/>
<arg value="-I/usr/X11R6/include"/>
+ <arg value="-I${native}"/>
<arg value="-I${native}/common"/>
<arg value="-I${native}/common/opengl"/>
<arg value="-I${native}/linux"/>
@@ -124,6 +135,7 @@
<arg value="-I/usr/X11R6/include"/>
<arg value="-I${native}/common"/>
<arg value="-I${native}/common/opengl"/>
+ <arg value="-I${native}"/>
<arg value="-I${native}/linux"/>
<arg value="-I${native}/linux/opengl"/>
<mapper type="glob" from="*.c" to="*.o"/>
@@ -0,0 +1,14 @@
Build with jdk-11
Index: platform_build/build-generator.xml
--- platform_build/build-generator.xml.orig
+++ platform_build/build-generator.xml
@@ -32,7 +32,7 @@
</javac>
<!-- Compile helper classes used by the templates -->
- <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.5" target="1.5" taskname="generator">
+ <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.6" target="1.6" taskname="generator">
<include name="org/lwjgl/PointerWrapper.java"/>
<include name="org/lwjgl/PointerBuffer.java"/>
<!-- OpenGL -->
@@ -0,0 +1,13 @@
Build with jdk-11
Index: src/java/org/lwjgl/LinuxSysImplementation.java
--- src/java/org/lwjgl/LinuxSysImplementation.java.orig
+++ src/java/org/lwjgl/LinuxSysImplementation.java
@@ -43,6 +43,7 @@ import java.lang.UnsatisfiedLinkError;
* $Id: patch-src_java_org_lwjgl_LinuxSysImplementation_java,v 1.1 2025/12/24 15:40:31 kurt Exp $
*/
final class LinuxSysImplementation extends J2SESysImplementation {
+ @java.lang.annotation.Native
private static final int JNI_VERSION = 19;
static {
@@ -0,0 +1,13 @@
Build with jdk-11
Index: src/java/org/lwjgl/MacOSXSysImplementation.java
--- src/java/org/lwjgl/MacOSXSysImplementation.java.orig
+++ src/java/org/lwjgl/MacOSXSysImplementation.java
@@ -44,6 +44,7 @@ import java.lang.UnsatisfiedLinkError;
* $Id: patch-src_java_org_lwjgl_MacOSXSysImplementation_java,v 1.1 2025/12/24 15:40:31 kurt Exp $
*/
final class MacOSXSysImplementation extends J2SESysImplementation {
+ @java.lang.annotation.Native
private static final int JNI_VERSION = 25;
static {
@@ -0,0 +1,53 @@
Build with jdk-11
Index: src/java/org/lwjgl/MemoryUtilSun.java
--- src/java/org/lwjgl/MemoryUtilSun.java.orig
+++ src/java/org/lwjgl/MemoryUtilSun.java
@@ -37,7 +37,6 @@ import java.lang.reflect.Modifier;
import java.nio.Buffer;
import sun.misc.Unsafe;
-import sun.reflect.FieldAccessor;
/**
* MemoryUtil.Accessor implementations that depend on sun.misc.
@@ -99,37 +98,8 @@ final class MemoryUtilSun {
}
throw new UnsupportedOperationException();
- }
-
- }
-
- /** Implementation using reflection on ByteBuffer, FieldAccessor is used directly. */
- private static class AccessorReflectFast implements MemoryUtil.Accessor {
-
- private final FieldAccessor addressAccessor;
-
- AccessorReflectFast() {
- Field address;
- try {
- address = MemoryUtil.getAddressField();
- } catch (NoSuchFieldException e) {
- throw new UnsupportedOperationException(e);
- }
- address.setAccessible(true);
-
- try {
- Method m = Field.class.getDeclaredMethod("acquireFieldAccessor", boolean.class);
- m.setAccessible(true);
- addressAccessor = (FieldAccessor)m.invoke(address, true);
- } catch (Exception e) {
- throw new UnsupportedOperationException(e);
- }
- }
-
- public long getAddress(final Buffer buffer) {
- return addressAccessor.getLong(buffer);
}
}
-}
\ No newline at end of file
+}
@@ -0,0 +1,22 @@
Build with jdk-11
Index: src/java/org/lwjgl/input/Cursor.java
--- src/java/org/lwjgl/input/Cursor.java.orig
+++ src/java/org/lwjgl/input/Cursor.java
@@ -51,12 +51,15 @@ import org.lwjgl.Sys;
public class Cursor {
/** 1 bit transparency for native cursor */
+ @java.lang.annotation.Native
public static final int CURSOR_ONE_BIT_TRANSPARENCY = 1;
- /** 8 bit alhpa native cursor */
+ /** 8 bit alpha native cursor */
+ @java.lang.annotation.Native
public static final int CURSOR_8_BIT_ALPHA = 2;
/** animation native cursor */
+ @java.lang.annotation.Native
public static final int CURSOR_ANIMATION = 4;
/** First element to display */
@@ -0,0 +1,13 @@
Build with jdk-11
Index: src/java/org/lwjgl/opengl/Pbuffer.java
--- src/java/org/lwjgl/opengl/Pbuffer.java.orig
+++ src/java/org/lwjgl/opengl/Pbuffer.java
@@ -52,6 +52,7 @@ public final class Pbuffer extends DrawableGL {
/**
* Indicates that Pbuffers can be created.
*/
+ @java.lang.annotation.Native
public static final int PBUFFER_SUPPORTED = 1 << 0;
/**
@@ -0,0 +1,16 @@
Build with jdk-11
Index: src/java/org/lwjgl/util/generator/GeneratorVisitor.java
--- src/java/org/lwjgl/util/generator/GeneratorVisitor.java.orig
+++ src/java/org/lwjgl/util/generator/GeneratorVisitor.java
@@ -300,8 +300,8 @@ public class GeneratorVisitor extends ElementKindVisit
}
// TODO: Back-port LWJGL 3's generation file handling (generate in-memory and avoid touching files if nothing has changed)
- java_writer = new PrintWriter(env.getFiler().createSourceFile(Utils.getQualifiedClassName(e), env.getElementUtils().getPackageOf(e)).openWriter());
- generateJavaSource(e, java_writer);
+ outputJava.getParentFile().mkdirs();
+ generateJavaSource(e, new PrintWriter(new java.io.FileWriter(outputJava)));
if ( methods.size() > 0 ) {
boolean noNative = true;
@@ -0,0 +1,10 @@
Build with jdk-11
Index: src/native/common/org_lwjgl_BufferUtils.c
--- src/native/common/org_lwjgl_BufferUtils.c.orig
+++ src/native/common/org_lwjgl_BufferUtils.c
@@ -1,4 +1,3 @@
-#include "org_lwjgl_BufferUtils.h"
#include "common_tools.h"
JNIEXPORT void JNICALL Java_org_lwjgl_BufferUtils_zeroBuffer0(JNIEnv *env, jclass clazz, jobject buffer, jlong offset, jlong size) {
@@ -0,0 +1,13 @@
Build with jdk-11
Index: src/native/common/org_lwjgl_opencl_CallbackUtil.c
--- src/native/common/org_lwjgl_opencl_CallbackUtil.c.orig
+++ src/native/common/org_lwjgl_opencl_CallbackUtil.c
@@ -39,7 +39,6 @@
#include <jni.h>
#include "common_tools.h"
#include "extcl.h"
-#include "org_lwjgl_opencl_CallbackUtil.h"
static jmethodID contextCallbackJ;
static jmethodID memObjectDestructorCallbackJ;
@@ -0,0 +1,13 @@
Build with jdk-11
Index: src/native/linux/opengl/org_lwjgl_opengl_Pbuffer.c
--- src/native/linux/opengl/org_lwjgl_opengl_Pbuffer.c.orig
+++ src/native/linux/opengl/org_lwjgl_opengl_Pbuffer.c
@@ -42,6 +42,7 @@
#include <stdlib.h>
#include "org_lwjgl_opengl_LinuxPbufferPeerInfo.h"
#include "org_lwjgl_opengl_Pbuffer.h"
+#include "org_lwjgl_opengl_LinuxDisplay.h"
#include "extgl.h"
#include "context.h"
#include "common_tools.h"