Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ELY-2514] Update minimum JDK for all modules to 11 #2109

Open
wants to merge 3 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 0 additions & 58 deletions manager/base/pom.xml
Expand Up @@ -35,64 +35,6 @@
<name>WildFly Elytron - Security Manager</name>
<description>WildFly Security Security Manager</description>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0-jboss-1</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>8</release>
<buildDirectory>${project.build.directory}</buildDirectory>
<compileSourceRoots>${project.compileSourceRoots}</compileSourceRoots>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.directory}/jdk-misc.jar</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</execution>
<execution>
<id>compile-java9</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>9</release>
<buildDirectory>${project.build.directory}</buildDirectory>
<compileSourceRoots>${project.basedir}/src/main/java9</compileSourceRoots>
<outputDirectory>${project.build.directory}/classes/META-INF/versions/9</outputDirectory>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.outputDirectory}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${version.jar.plugin}</version>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
<Jar-Version>${project.version}</Jar-Version>
<Jar-Name>${project.artifactId}</Jar-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.wildfly.security</groupId>
Expand Down
Expand Up @@ -17,42 +17,43 @@
*/
package org.wildfly.security.manager;

import sun.reflect.Reflection;
import static java.security.AccessController.doPrivileged;

import java.lang.StackWalker.Option;
import java.security.PrivilegedAction;
import java.util.List;
import java.util.stream.Collectors;

/**
* JDK-specific classes which are replaced for different JDK major versions. This class is for JDK 8.
* JDK-specific classes which are replaced for different JDK major versions. This class is for JDK 9.
* @author <a href="mailto:jucook@redhat.com">Justin Cook</a>
*/
final class JDKSpecific {

private static boolean active;
private static int offset;

static {

boolean active = false;
int offset = 0;
try {
// JDK-8014925 - An additional Reflection call may be on the call stack so check the offset needed.
active = Reflection.getCallerClass(1) == WildFlySecurityManager.class || Reflection.getCallerClass(2) == WildFlySecurityManager.class;
offset = Reflection.getCallerClass(1) == Reflection.class ? 2 : 1;
} catch (Throwable ignored) {}

JDKSpecific.active = active;
// JDKSpecific.getCallerClass will also add 1 to the stack.
JDKSpecific.offset = offset + 1;
/*
* Using StackWalker the OFFSET is the minimum number of StackFrames, the first will always be
* JDKSpecific,getCallerClass(int), the second will always be the caller of this class.
*/
private static final int OFFSET = 2;

public static Class<?> getCallerClass(int n){
// Although we know WildFlySecurityManager is making the call it may not be the actual SecurityManager
// so we need to use doPrivileged instead of a doUnchecked unless we can be sure checking has been switched off.
final StackWalker stackWalker = WildFlySecurityManager.isChecking() ?
doPrivileged((PrivilegedAction<StackWalker>)JDKSpecific::getStackWalker) : getStackWalker();

List<StackWalker.StackFrame> frames = stackWalker.walk(s ->
s.limit(n + OFFSET).collect(Collectors.toList())
);
return frames.get(frames.size() - 1).getDeclaringClass();
}

public static Class<?> getCallerClass(int n) {
if (active) {
return Reflection.getCallerClass(n + offset);
} else {
throw new IllegalStateException("sun.reflect.Reflect.getCallerClass(int) not available.");
}
private static StackWalker getStackWalker() {
return StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE);
}

public static boolean usingStackWalker() {
return false;
return true;
}

}

This file was deleted.

110 changes: 4 additions & 106 deletions pom.xml
Expand Up @@ -55,7 +55,9 @@
</scm>

<properties>
<jdk.min.version>11</jdk.min.version>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<version.com.fasterxml.jackson>2.15.4</version.com.fasterxml.jackson>
<version.com.fasterxml.jackson.databind>${version.com.fasterxml.jackson}</version.com.fasterxml.jackson.databind>
<version.commons-cli>1.6.0</version.commons-cli>
Expand Down Expand Up @@ -102,10 +104,6 @@
<test.level>INFO</test.level>
<!-- Checkstyle configuration -->
<linkXRef>false</linkXRef>

<!-- Modularized JDK support (various workarounds) - activated via profile -->
<modular.jdk.args/>
<modular.jdk.props/>
</properties>

<build>
Expand Down Expand Up @@ -140,7 +138,6 @@
<goal>compile</goal>
</goals>
<configuration>
<release>8</release>
<buildDirectory>${project.build.directory}</buildDirectory>
<compileSourceRoots>${project.compileSourceRoots}</compileSourceRoots>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
Expand Down Expand Up @@ -194,17 +191,6 @@
<reuseForks>false</reuseForks>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
</configuration>
<executions>
<execution>
<id>default-test</id>
<configuration>
<classesDirectory>${project.build.directory}/classes/META-INF/versions/9</classesDirectory>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.directory}/classes</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
Expand Down Expand Up @@ -238,7 +224,7 @@
</includes>
<childDelegation>true</childDelegation>
<reuseForks>false</reuseForks>
<argLine>-javaagent:${settings.localRepository}/org/jmockit/jmockit/${version.jmockit}/jmockit-${version.jmockit}.jar ${modular.jdk.args} ${modular.jdk.props}</argLine>
<argLine>-javaagent:${settings.localRepository}/org/jmockit/jmockit/${version.jmockit}/jmockit-${version.jmockit}.jar</argLine>
<!-- See also excludedGroups property in profiles -->
</configuration>
</plugin>
Expand Down Expand Up @@ -295,7 +281,6 @@
${project.basedir}/json-util/src/main/java/;
${project.basedir}/keystore/src/main/java/;
${project.basedir}/manager/action/src/main/java/;
${project.basedir}/manager/base/src/main/java9/; <!--java9/ must be before java/-->
${project.basedir}/manager/base/src/main/java/;
${project.basedir}/mechanism/base/src/main/java/;
${project.basedir}/mechanism/digest/src/main/java/;
Expand Down Expand Up @@ -1240,21 +1225,6 @@
</dependencyManagement>

<profiles>
<profile>
<id>modularizedJdk</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<!-- [WFCORE-1431] remove SASL workaround -->
<modular.jdk.args>--add-modules java.sql --illegal-access=permit</modular.jdk.args>
<!-- use version of jboss-logging that works much better with JDK9 -->
<modular.jdk.props>-Djdk.attach.allowAttachSelf=true</modular.jdk.props>
<!-- 2.20.x doesn't start on JDK10-->
<version.surefire.plugin>2.19.1</version.surefire.plugin>
</properties>
</profile>

<profile>
<id>skip-default-tests</id>
<build>
Expand All @@ -1271,78 +1241,6 @@
</plugins>
</build>
</profile>
<profile>
<id>java8-test-profile</id>
<activation>
<property>
<name>java8.home</name>
</property>
</activation>
<properties>
<modular.jdk.args/>
<modular.jdk.props/>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>java8-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports/java8</reportsDirectory>
<jvm>${java8.home}/bin/java</jvm>
<additionalClasspathElements>
<additionalClasspathElement>${java8.home}/lib/tools.jar</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>java9-test-profile</id>
<activation>
<property>
<name>java9.home</name>
</property>
</activation>
<properties>
<modular.jdk.args/>
<modular.jdk.props/>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>java9-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports/java9</reportsDirectory>
<jvm>${java9.home}/bin/java</jvm>
<classesDirectory>${project.build.directory}/classes/META-INF/versions/9</classesDirectory>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.outputDirectory}</additionalClasspathElement>
<additionalClasspathElement>${java9.home}/lib/tools.jar</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<repositories>
Expand Down