-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Statically linked JavaNImpl classes, utilizing "JEP 238: Multi-Releas…
…e JAR Files"
- Loading branch information
Showing
14 changed files
with
211 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
freemarker-core/src/main/java/freemarker/core/_Java16Impl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package freemarker.core; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Set; | ||
|
||
/** | ||
* Used internally only, might change without notice! | ||
* Pre-Java-16 implementation of {@link _Java16}. | ||
*/ | ||
// We also have a Java 16 versions of this class in freemarker-core16, and we put all versions into | ||
// the jar artifact via "JEP 238: Multi-Release JAR Files". | ||
public final class _Java16Impl implements _Java16 { | ||
@Override | ||
public boolean isSupported() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isRecord(Class<?> cl) { | ||
throw newNoRecordSupportException(); | ||
} | ||
|
||
@Override | ||
public Set<Method> getComponentAccessors(Class<?> recordClass){ | ||
throw newNoRecordSupportException(); | ||
} | ||
|
||
private UnsupportedOperationException newNoRecordSupportException() { | ||
return new UnsupportedOperationException("Record support needs at least Java 16"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
freemarker-core/src/main/java/freemarker/core/_Java9Impl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package freemarker.core; | ||
|
||
/** | ||
* Used internally only, might change without notice! | ||
* Pre-Java-9 implementation of {@link _Java9}. | ||
*/ | ||
// We also have a Java 9 versions of this class in freemarker-core9, and we put all versions into | ||
// the jar artifact via "JEP 238: Multi-Release JAR Files". | ||
public class _Java9Impl implements _Java9 { | ||
@Override | ||
public boolean isSupported() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isAccessibleAccordingToModuleExports(Class<?> m) { | ||
throw new UnsupportedOperationException("Requires at least Java 9"); | ||
} | ||
} |
95 changes: 0 additions & 95 deletions
95
freemarker-core/src/main/java/freemarker/core/_JavaVersions.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
freemarker-core16/src/test/java/freemarker/ext/beans/Java16TestClassLoadingCorrectTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package freemarker.ext.beans; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Test; | ||
|
||
import freemarker.core._Java16; | ||
import freemarker.core._Java16Impl; | ||
|
||
public class Java16TestClassLoadingCorrectTest { | ||
@Test | ||
public void java16Supported() { | ||
// This can be a problem if the test is not ran from the jar, and the impl class from the core takes precedence | ||
assertTrue( | ||
"Multi-Release JAR selection of the proper " + _Java16Impl.class.getName() + " variant didn't happen in the Java 16 test environment", | ||
_Java16.INSTANCE.isSupported()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.