-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4.1.1.bytecode.1: Indy and Nests edition.
- Support for Java 11 Nest Based Access Control - Default to Java 16 Major Version - Use `invokedynamic` for String Concatenation for Java 9 or later . - Consistent InvokeDynamic (koresframework/Kores#79). - Support Dynamic Constant - Support Field Specification - Better Method Specification
- Loading branch information
1 parent
eb4fef7
commit bb990b8
Showing
246 changed files
with
1,698 additions
and
541 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# 4.1.1.bytecode.1 | ||
|
||
- Support for Java 11 Nest Based Access Control | ||
- Default to Java 16 Major Version | ||
- Use `invokedynamic` for String Concatenation for Java 9 or later . | ||
- Consistent InvokeDynamic (https://github.com/koresframework/Kores/issues/79). | ||
- Support Dynamic Constant | ||
- Support Field Specification | ||
- Better Method Specification | ||
|
||
# 4.0.4.bytecode.1 - Not Found Edition | ||
|
||
- Serialization support and updated to new `Literals` structure. |
Submodule Kores
updated
3290 files
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* | ||
|
@@ -35,6 +35,9 @@ import com.github.jonathanxd.kores.bytecode.post.GotoOptimizer | |
import com.github.jonathanxd.kores.bytecode.post.MethodProcessor | ||
import com.github.jonathanxd.kores.bytecode.pre.GenLineVisitor | ||
import com.github.jonathanxd.iutils.option.Option | ||
import com.github.jonathanxd.iutils.option.Options | ||
import com.github.jonathanxd.kores.bytecode.doc.NestLogic | ||
import com.github.jonathanxd.kores.bytecode.doc.IndyConcatLogic | ||
|
||
/** | ||
* Calls [org.objectweb.asm.util.CheckClassAdapter] to check generated class. | ||
|
@@ -115,6 +118,194 @@ val GENERATE_BRIDGE_METHODS = Option(false) | |
@JvmField | ||
val GENERATE_SYNTHETIC_ACCESS = Option(true) | ||
|
||
/** | ||
* Automatically generate synthetic accessors for private members in private inner classes. | ||
* Synthetic accessors will be only generated for private members which are accessed. | ||
* | ||
* An anonymous synthetic class may be generated for private constructors. | ||
* | ||
* @since 4.0.5.bytecode.5 | ||
*/ | ||
@JvmField | ||
val FORCE_GENERATE_SYNTHETIC_ACCESS = Option(false) | ||
|
||
/** | ||
* When enabled, generate nests declarations as specified in [JEP 181](https://openjdk.java.net/jeps/181), | ||
* enabling this automatically disables [GENERATE_SYNTHETIC_ACCESS]. | ||
* | ||
* To have both enabled, use [FORCE_GENERATE_SYNTHETIC_ACCESS]. This is not recommended since | ||
* [Nest-Based Access Control](https://openjdk.java.net/jeps/181) introduces JVM-Level access control | ||
* and removes the need of having bridge methods to access inner classes private members. | ||
* | ||
* @since 4.0.5.bytecode.5 | ||
*/ | ||
@JvmField | ||
val GENERATE_NESTS = Option(true) | ||
|
||
/** | ||
* Force generate [Nests](https://openjdk.java.net/jeps/181) even when emitting bytecode for Java 10 (54) or earlier. | ||
* | ||
* Note that forcing to generate Nests may result in two scenarios: | ||
* | ||
* - Generate Nests info but invoke with **synthetic accessors** when [FORCE_GENERATE_SYNTHETIC_ACCESS] is set. | ||
* - Generate Nests info and access members directly. JVM may not accept this kind of access when running under Java 10 or earlier. | ||
* | ||
* Read more at [GENERATE_NESTS]. | ||
*/ | ||
@JvmField | ||
val FORCE_GENERATE_NESTS = Option(true) | ||
|
||
/** | ||
* Uses `invokedynamic` instruction for string concatenation instead of [StringBuilder]. | ||
* | ||
* This option is automatically disabled when emitting bytecode for Java 8 or earlier, to force use [FORCE_INDIFY_STRING_CONCAT]. | ||
* | ||
* Read more at [IndyConcatLogic] | ||
*/ | ||
@JvmField | ||
val INDIFY_STRING_CONCAT = Option(true) | ||
|
||
/** | ||
* Force the use of `invokedynamic` instruction for string concatenation instead of [StringBuilder]. | ||
* | ||
* This applies even if the target bytecode version is lower or equal to 52 (Java 8), so the concatenation will | ||
* only work when running under Java 9 or newer. | ||
* | ||
* Read [INDIFY_STRING_CONCAT] for more information. | ||
*/ | ||
@JvmField | ||
val FORCE_INDIFY_STRING_CONCAT = Option(false) | ||
|
||
/** | ||
* Specifies the strategy to use to generate `invokedynamic` string concatenation, as specified in | ||
* [java.lang.invoke.StringConcatFactory.makeConcatWithConstants]. | ||
* | ||
* Read more at [IndyConcatLogic]. | ||
*/ | ||
@JvmField | ||
val INDY_CONCAT_STRATEGY = Option(IndyConcatStrategy.INTERPOLATE) | ||
|
||
enum class IndyConcatStrategy { | ||
/** | ||
* Indify using interpolation, the produced `invokedynamic` instruction interpolates the constants in the | ||
* [recipe][java.lang.invoke.StringConcatFactory.makeConcatWithConstants] argument. | ||
* | ||
* For example, the following concatenation scenario: | ||
* | ||
* ```kotlin | ||
* fun concat(a: String, b: String) = | ||
* a + "<:>" + b | ||
* ``` | ||
* | ||
* Is translated into the following recipe: | ||
* ``` | ||
* aload 0 // Load a | ||
* aload 1 // Load b | ||
* makeConcatWithConstants<invokedynamic>("\u0001<:>\u0001") | ||
* ``` | ||
* | ||
*/ | ||
INTERPOLATE, | ||
|
||
/** | ||
* Indify providing constants to the [bootstrap method constants parameter][java.lang.invoke.StringConcatFactory.makeConcatWithConstants]. | ||
* This results in an interpolation using `\u0001` for arguments in the stack and `\u0002` for constants in the **ConstantPool**. | ||
* | ||
* For example, the following concatenation scenario: | ||
* | ||
* ```kotlin | ||
* fun concat(a: String, b: String) = | ||
* a + "<:>" + b | ||
* ``` | ||
* | ||
* Is translated into the following recipe: | ||
* ``` | ||
* aload 0 // Load a | ||
* aload 1 // Load b | ||
* | ||
* makeConcatWithConstants<invokedynamic>("\u0001\u0002\u0001", "<:>") | ||
* ``` | ||
* | ||
* With `<:>` provided as an argument to the [bootstrap method constants parameter][java.lang.invoke.StringConcatFactory.makeConcatWithConstants]. | ||
*/ | ||
CONSTANT, | ||
|
||
/** | ||
* Indify using only arguments in the stack. Constant values are pushed to the stack using `ldc` instruction. | ||
* | ||
* For example, the following concatenation scenario: | ||
* | ||
* ```kotlin | ||
* fun concat(a: String, b: String) = | ||
* a + "<:>" + b | ||
* ``` | ||
* | ||
* Is translated into the following recipe: | ||
* ``` | ||
* aload 0 // Load a | ||
* ldc "<:>" | ||
* aload 1 // Load b | ||
* makeConcatWithConstants<invokedynamic>("\u0001\u0001\u0001") | ||
* ``` | ||
*/ | ||
LDC | ||
} | ||
|
||
/** | ||
* Read more in [NestLogic] | ||
*/ | ||
fun Options.nestAccessGenerationMode(version: Int) = | ||
when { | ||
this[FORCE_GENERATE_SYNTHETIC_ACCESS] == true && this[GENERATE_NESTS] == true && version >= 55 -> NestAccessGenerationMode.MIXED | ||
this[FORCE_GENERATE_SYNTHETIC_ACCESS] == true && this[FORCE_GENERATE_NESTS] == true -> NestAccessGenerationMode.MIXED | ||
this[FORCE_GENERATE_NESTS] == true -> NestAccessGenerationMode.NEST_BASED | ||
this[GENERATE_NESTS] == true && version >= 55 -> NestAccessGenerationMode.NEST_BASED | ||
this[GENERATE_SYNTHETIC_ACCESS] == true -> NestAccessGenerationMode.SYNTHETIC_ONLY | ||
else -> NestAccessGenerationMode.DISABLED | ||
} | ||
|
||
/** | ||
* Read more in [NestLogic] | ||
*/ | ||
enum class NestAccessGenerationMode { | ||
/** | ||
* Synthetic and Bridge based inner class private member access. | ||
*/ | ||
SYNTHETIC_ONLY, | ||
|
||
/** | ||
* Nest-based inner class private member access, as specified in [JEP 181](https://openjdk.java.net/jeps/181). | ||
*/ | ||
NEST_BASED, | ||
|
||
/** | ||
* Mixed, generate NestHost and NestMember declarations, as specified in [JEP 181](https://openjdk.java.net/jeps/181), | ||
* but use **Synthetic Bridge Methods** for access instead of direct access. | ||
* | ||
* Not recommended since [Nest-Based Access Control](https://openjdk.java.net/jeps/181) allows direct access to private | ||
* members without **bridge methods**. This should only be used in **very very very** specific cases. | ||
*/ | ||
MIXED, | ||
|
||
/** | ||
* Totally disabled. This may cause **class load-time** and/or **runtime exceptions** in most JVM Implementations | ||
* since classes are not allowed to access private members. | ||
*/ | ||
DISABLED | ||
} | ||
|
||
/** | ||
* Read more in [NestLogic] | ||
*/ | ||
fun NestAccessGenerationMode.isSyntheticAccess() = | ||
this == NestAccessGenerationMode.SYNTHETIC_ONLY || this == NestAccessGenerationMode.MIXED | ||
|
||
/** | ||
* Read more in [NestLogic] | ||
*/ | ||
fun NestAccessGenerationMode.isToGenerateNests() = | ||
this == NestAccessGenerationMode.MIXED || this == NestAccessGenerationMode.NEST_BASED | ||
|
||
enum class VisitLineType { | ||
/** | ||
* Disable line visit | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* | ||
|
Oops, something went wrong.