Skip to content

Commit

Permalink
Java 8 compatibility. Close #177
Browse files Browse the repository at this point in the history
LWJGL now requires Java 8 or newer to build and run.
  • Loading branch information
Spasi committed Apr 16, 2016
1 parent eb43673 commit 1096ab7
Show file tree
Hide file tree
Showing 73 changed files with 955 additions and 1,348 deletions.
4 changes: 2 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,14 @@ License terms: http://lwjgl.org/license.php
<src path="${src.templates}/java"/>
<include name="org/lwjgl/system/**"/>
<classpath>
<pathelement location="${env.JAVA_HOME}/lib/tools.jar" unless:set="jdk.apple"/>
<pathelement location="${env.JAVA_HOME}/lib/tools.jar"/>
</classpath>
</lwjgl.javac>

<delete dir="${bin.html.javadoc}"/>
<javadoc
destdir="${bin.html.javadoc}"
source="1.6"
source="1.8"
windowtitle="LWJGL ${build.version}"
encoding="UTF-8"
docencoding="UTF-8"
Expand Down
21 changes: 5 additions & 16 deletions config/build-definitions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ This script is included in /build.xml and /config/update-dependencies.xml.
<property name="bin.templates" location="${bin}/Templates" relative="true"/>
<property name="bin.core" location="${bin}/Core" relative="true"/>
<property name="bin.tests" location="${bin}/Tests" relative="true"/>
<property name="bin.html.tests" location="${bin}/HTML/tests" relative="true"/>
<property name="bin.html.javadoc" location="${bin}/HTML/javadoc" relative="true"/>

<property name="bin.html" location="${bin}/HTML" relative="true"/>
<property name="bin.html.tests" location="${bin.html}/tests" relative="true"/>
<property name="bin.html.javadoc" location="${bin.html}/javadoc" relative="true"/>

<property name="test.resources" location="${module.core}/src/test/resources" relative="true"/>

Expand Down Expand Up @@ -132,22 +134,9 @@ This script is included in /build.xml and /config/update-dependencies.xml.
<!-- Different location per platform/architecture. This is intentional. -->
<property name="bin.native" location="${bin}/${platform}/${build.arch}" relative="true"/>

<available property="jdk.apple" file="${env.JAVA6_HOME}/bundle/Classes/classes.jar" if:set="env.JAVA6_HOME"/>
<presetdef name="lwjgl.javac">
<javac sourcepath="" debug="yes" encoding="UTF-8" source="1.6" target="1.6">
<!-- JAVA6_HOME will be used for the bootclasspath. This will cause compilation to fail if a Java 7+ API is used by mistake. -->
<bootclasspath if:set="env.JAVA6_HOME">
<!-- OpenJDK -->
<fileset dir="${env.JAVA6_HOME}/jre/lib" unless:set="jdk.apple">
<include name="*.jar"/>
</fileset>
<!-- Apple JDK -->
<fileset dir="${env.JAVA6_HOME}/bundle/Classes" if:set="jdk.apple">
<include name="*.jar"/>
</fileset>
</bootclasspath>
<javac sourcepath="" debug="yes" encoding="UTF-8" source="1.8" target="1.8">
<compilerarg value="-Xlint:all"/>
<compilerarg value="-Xlint:-options" unless:set="env.JAVA6_HOME"/>
</javac>
</presetdef>

Expand Down
25 changes: 5 additions & 20 deletions config/ide/idea/.idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions config/ide/idea/.idea/inspectionProfiles/LWJGL.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/ide/idea/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/ide/idea/.idea/runConfigurations/TESTS.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ Library Dependencies: Kotlin runtime

# INSTALLATION
Requirements:
* JDK 6 or newer
See *JAVA6_HOME* below for more info.
* JDK 8 or newer
* Ant 1.9.3 or newer

Step-by-step:
Expand Down Expand Up @@ -86,8 +85,6 @@ The config folder contains the LWJGL configuration.
- a config/tests_<platform>.xml per platform

The ANT build can be configured with the following environment variables:
* JAVA6_HOME (optional, recommended)
Should point to a JDK 6. This is used to configure the javac *bootclasspath* to ensure that the source code is compatible with Java 6. This is only useful if you plan to make changes to the LWJGL source code.
* LWJGL_BUILD_TYPE (optional)
This is used as the source of binary dependencies. Valid values:
- *nightly*
Expand Down
13 changes: 4 additions & 9 deletions modules/core/src/main/java/org/lwjgl/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,10 @@ private static String getVersionImpl() {
if ( url != null ) {
String classURL = url.toString();
if ( classURL.startsWith("jar:") ) {
try {
InputStream stream = new URL(classURL.substring(0, classURL.lastIndexOf("!") + 1) + '/' + JarFile.MANIFEST_NAME).openStream();
try {
return new Manifest(stream)
.getAttributes("org/lwjgl/")
.getValue("Implementation-Version");
} finally {
stream.close();
}
try ( InputStream stream = new URL(classURL.substring(0, classURL.lastIndexOf("!") + 1) + '/' + JarFile.MANIFEST_NAME).openStream() ) {
return new Manifest(stream)
.getAttributes("org/lwjgl/")
.getValue("Implementation-Version");
} catch (Exception e) {
e.printStackTrace(APIUtil.DEBUG_STREAM);
}
Expand Down
8 changes: 4 additions & 4 deletions modules/core/src/main/java/org/lwjgl/egl/EGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public static void create(String libName) {
create(Library.loadNative(libName));
}

private static void create(final SharedLibrary EGL) {
private static void create(SharedLibrary EGL) {
try {
FunctionProvider functionProvider = new FunctionProvider.Default() {
FunctionProvider functionProvider = new FunctionProvider() {
private final long eglGetProcAddress = EGL.getFunctionAddress("eglGetProcAddress");

{
Expand Down Expand Up @@ -156,7 +156,7 @@ private static EGLCapabilities createClientCapabilities() {
long QueryString = functionProvider.getFunctionAddress("eglQueryString");
long versionString = invokePIP(QueryString, EGL_NO_DISPLAY, EGL_VERSION);

Set<String> ext = new HashSet<String>(32);
Set<String> ext = new HashSet<>(32);

if ( versionString == NULL )
invokeI(functionProvider.getFunctionAddress("eglGetError")); // clear error
Expand All @@ -182,7 +182,7 @@ private static EGLCapabilities createClientCapabilities() {
* @return the {@link EGLCapabilities instance}
*/
public static EGLCapabilities createDisplayCapabilities(long dpy, int majorVersion, int minorVersion) {
Set<String> supportedExtensions = new HashSet<String>(32);
Set<String> supportedExtensions = new HashSet<>(32);

// Add EGL versions
addEGLVersions(majorVersion, minorVersion, supportedExtensions);
Expand Down
11 changes: 2 additions & 9 deletions modules/core/src/main/java/org/lwjgl/egl/EGLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package org.lwjgl.egl;

import java.lang.reflect.Field;
import java.util.Map;

import static org.lwjgl.egl.EGL10.*;
Expand All @@ -14,13 +13,7 @@
public final class EGLUtil {

private static final Map<Integer, String> EGL_ERROR_TOKENS = apiClassTokens(
new TokenFilter() {
@Override
public boolean accept(Field field, int value) {
return field.getName().contains("_BAD_");
}
},
null,
(field, value) -> field.getName().contains("_BAD_"), null,
EGL10.class,
EGL11.class,
EXTDeviceQuery.class,
Expand Down Expand Up @@ -70,7 +63,7 @@ public static String getErrorString(int errorCode) {
return "An EGLNativeWindowType argument does not refer to a valid native window.";
case EGL_CONTEXT_LOST:
return "A power management event has occurred. The application must destroy all contexts and reinitialise client API state and objects to " +
"continue rendering.";
"continue rendering.";
case EXTDeviceQuery.EGL_BAD_DEVICE_EXT:
return "An EGLDeviceEXT argument does not refer to a valid EGLDeviceEXT.";
case EXTOutputBase.EGL_BAD_OUTPUT_LAYER_EXT:
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/main/java/org/lwjgl/glfw/Callbacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.nio.IntBuffer;

import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.system.Checks.checkPointer;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryStack.*;
import static org.lwjgl.system.MemoryUtil.*;
Expand Down
5 changes: 1 addition & 4 deletions modules/core/src/main/java/org/lwjgl/glfw/EventLoop.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
*/
package org.lwjgl.glfw;

import org.lwjgl.system.Configuration;
import org.lwjgl.system.Library;
import org.lwjgl.system.Platform;
import org.lwjgl.system.SharedLibrary;
import org.lwjgl.system.*;
import org.lwjgl.system.macosx.ObjCRuntime;

import static org.lwjgl.system.APIUtil.*;
Expand Down
8 changes: 4 additions & 4 deletions modules/core/src/main/java/org/lwjgl/openal/AL.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ else if ( "ThreadLocal".equals(capsStateType) )
private AL() {}

static void init() {
functionProvider = new FunctionProvider.Default() {
functionProvider = new FunctionProvider() {
// We'll use alGetProcAddress for both core and extension entry points.
// To do that, we need to first grab the alGetProcAddress function from
// the OpenAL native library.
Expand Down Expand Up @@ -170,7 +170,7 @@ public static ALCapabilities createCapabilities(ALCCapabilities alcCaps) {
{ 0, 1 } // OpenAL 1
};

Set<String> supportedExtensions = new HashSet<String>(32);
Set<String> supportedExtensions = new HashSet<>(32);

for ( int major = 1; major <= AL_VERSIONS.length; major++ ) {
int[] minors = AL_VERSIONS[major - 1];
Expand Down Expand Up @@ -248,8 +248,8 @@ private static class StaticCapabilitiesState implements CapabilitiesState {
if ( Checks.DEBUG ) {
Field[] fields = ALCapabilities.class.getFields();

flags = new ArrayList<Field>(64);
funcs = new ArrayList<Field>(16);
flags = new ArrayList<>(64);
funcs = new ArrayList<>(16);

for ( Field f : fields )
(f.getType() == Boolean.TYPE ? flags : funcs).add(f);
Expand Down
10 changes: 5 additions & 5 deletions modules/core/src/main/java/org/lwjgl/openal/ALC.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import static org.lwjgl.openal.ALC10.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.checkPointer;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryStack.*;
import static org.lwjgl.system.MemoryUtil.*;
Expand Down Expand Up @@ -73,10 +73,10 @@ public static void create() {
* @param libName the native library name
*/
public static void create(String libName) {
final SharedLibrary OPENAL = Library.loadNative(libName);
SharedLibrary OPENAL = Library.loadNative(libName);

try {
FunctionProviderLocal functionProvider = new FunctionProviderLocal.Default() {
FunctionProviderLocal functionProvider = new FunctionProviderLocal() {

private final long alcGetProcAddress = getFunctionAddress("alcGetProcAddress");

Expand Down Expand Up @@ -126,7 +126,7 @@ public static void create(FunctionProviderLocal functionProvider) {

ALC.functionProvider = functionProvider;

icd = new ALCCapabilities(functionProvider, NULL, Collections.<String>emptySet());
icd = new ALCCapabilities(functionProvider, NULL, Collections.emptySet());

AL.init();
}
Expand Down Expand Up @@ -189,7 +189,7 @@ public static ALCCapabilities createCapabilities(long device) {
{ 0, 1 }, // ALC 1
};

Set<String> supportedExtensions = new HashSet<String>(16);
Set<String> supportedExtensions = new HashSet<>(16);

for ( int major = 1; major <= ALC_VERSIONS.length; major++ ) {
int[] minors = ALC_VERSIONS[major - 1];
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/main/java/org/lwjgl/openal/ALUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static List<String> getStringList(long deviceHandle, int token) {

ByteBuffer buffer = memByteBuffer(__result, Integer.MAX_VALUE);

List<String> strings = new ArrayList<String>();
List<String> strings = new ArrayList<>();

int offset = 0;
while ( true ) {
Expand Down
Loading

0 comments on commit 1096ab7

Please sign in to comment.