Skip to content

Commit 5e2b1c1

Browse files
committed
Package rename
1 parent 4fdc715 commit 5e2b1c1

File tree

203 files changed

+1955
-1625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+1955
-1625
lines changed

Kores

Submodule Kores updated 7488 files

build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ buildscript {
1717

1818
}
1919

20-
group 'com.github.koresframework'
21-
version '4.1.10.bytecode.4'
20+
group 'com.koresframework'
21+
version '4.2.1.bytecode'
2222

2323
apply from: project(":Kores").file("gradle/common.gradle")
2424

@@ -59,7 +59,7 @@ dependencies {
5959
// with runtime dependency pointing to Kores published version
6060
//compile project(":Kores")
6161
compileOnly project(":Kores")
62-
runtimeOnly "com.github.koresframework:kores:4.1.9.base"
62+
runtimeOnly "com.koresframework:kores:4.2.1.base"
6363
implementation 'com.github.jonathanxd:bytecode-disassembler:2.4.1'
6464
implementation "org.ow2.asm:asm:9.2"
6565
implementation "org.ow2.asm:asm-analysis:9.2"

src/main/kotlin/com/github/jonathanxd/kores/bytecode/BytecodeClass.kt src/main/kotlin/com/koresframework/kores/bytecode/BytecodeClass.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2626
* THE SOFTWARE.
2727
*/
28-
package com.github.jonathanxd.kores.bytecode
28+
package com.koresframework.kores.bytecode
2929

3030
import com.github.jonathanxd.bytecodedisassembler.Disassembler
31-
import com.github.jonathanxd.kores.base.ModuleDeclaration
32-
import com.github.jonathanxd.kores.base.Named
33-
import com.github.jonathanxd.kores.base.TypeDeclaration
31+
import com.koresframework.kores.base.ModuleDeclaration
32+
import com.koresframework.kores.base.Named
33+
import com.koresframework.kores.base.TypeDeclaration
3434

3535
/**
3636
* @property declaration Declaration that produced [bytecode]. Common types are [TypeDeclaration] and [ModuleDeclaration].

src/main/kotlin/com/github/jonathanxd/kores/bytecode/BytecodeModule.kt src/main/kotlin/com/koresframework/kores/bytecode/BytecodeModule.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2626
* THE SOFTWARE.
2727
*/
28-
package com.github.jonathanxd.kores.bytecode
28+
package com.koresframework.kores.bytecode
2929

3030
import com.github.jonathanxd.bytecodedisassembler.Disassembler
31-
import com.github.jonathanxd.kores.base.ModuleDeclaration
31+
import com.koresframework.kores.base.ModuleDeclaration
3232

3333
class BytecodeModule constructor(val module: ModuleDeclaration, private val bytecode_: ByteArray) {
3434

src/main/kotlin/com/github/jonathanxd/kores/bytecode/BytecodeOptions.kt src/main/kotlin/com/koresframework/kores/bytecode/BytecodeOptions.kt

+13-13
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@
2727
*/
2828
@file:JvmName("BytecodeOptions")
2929

30-
package com.github.jonathanxd.kores.bytecode
30+
package com.koresframework.kores.bytecode
3131

32-
import com.github.jonathanxd.kores.base.Line
33-
import com.github.jonathanxd.kores.bytecode.post.DeadCodeRemover
34-
import com.github.jonathanxd.kores.bytecode.post.GotoOptimizer
35-
import com.github.jonathanxd.kores.bytecode.post.MethodProcessor
36-
import com.github.jonathanxd.kores.bytecode.pre.GenLineVisitor
32+
import com.koresframework.kores.base.Line
33+
import com.koresframework.kores.bytecode.post.DeadCodeRemover
34+
import com.koresframework.kores.bytecode.post.GotoOptimizer
35+
import com.koresframework.kores.bytecode.post.MethodProcessor
36+
import com.koresframework.kores.bytecode.pre.GenLineVisitor
3737
import com.github.jonathanxd.iutils.option.Option
3838
import com.github.jonathanxd.iutils.option.Options
39-
import com.github.jonathanxd.kores.bytecode.doc.NestLogic
40-
import com.github.jonathanxd.kores.bytecode.doc.IndyConcatLogic
39+
import com.koresframework.kores.bytecode.doc.NestLogic
40+
import com.koresframework.kores.bytecode.doc.IndyConcatLogic
4141

4242
/**
4343
* Calls [org.objectweb.asm.util.CheckClassAdapter] to check generated class.
@@ -97,14 +97,14 @@ val VALIDATE_SUPER = Option(true)
9797
* The generation of bridge methods will slow down the Generator, if you mind the performance
9898
* don't change this option.
9999
*
100-
* The generation of bridge methods is very limited, the [Bridge Generator][com.github.jonathanxd.kores.bytecode.util.BridgeUtil]
100+
* The generation of bridge methods is very limited, the [Bridge Generator][com.koresframework.kores.bytecode.util.BridgeUtil]
101101
* will inspect super-classes (and super-interfaces) and find the overridden method.
102-
* The [Bridge Generator][com.github.jonathanxd.kores.bytecode.util.BridgeUtil] will only inspect
103-
* [Java type][Class] and [Kores Type][com.github.jonathanxd.kores.base.TypeDeclaration].
104-
* If the super-class and/or super-interfaces is of another type, [Bridge Generator][com.github.jonathanxd.kores.bytecode.util.BridgeUtil]
102+
* The [Bridge Generator][com.koresframework.kores.bytecode.util.BridgeUtil] will only inspect
103+
* [Java type][Class] and [Kores Type][com.koresframework.kores.base.TypeDeclaration].
104+
* If the super-class and/or super-interfaces is of another type, [Bridge Generator][com.koresframework.kores.bytecode.util.BridgeUtil]
105105
* will ignore and the bridge method will not be generated.
106106
*
107-
* You could also bridge methods manually with [com.github.jonathanxd.kores.factory.bridgeMethod].
107+
* You could also bridge methods manually with [com.koresframework.kores.factory.bridgeMethod].
108108
*/
109109
@JvmField
110110
val GENERATE_BRIDGE_METHODS = Option(false)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
/*
2+
* Kores-BytecodeWriter - Translates Kores Structure to JVM Bytecode <https://github.com/JonathanxD/CodeAPI-BytecodeWriter>
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <jonathan.scripter@programmer.net>
7+
* Copyright (c) contributors
8+
*
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a copy
11+
* of this software and associated documentation files (the "Software"), to deal
12+
* in the Software without restriction, including without limitation the rights
13+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
* copies of the Software, and to permit persons to whom the Software is
15+
* furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26+
* THE SOFTWARE.
27+
*/
28+
package com.koresframework.kores.bytecode.classloader
29+
30+
import com.koresframework.kores.base.TypeDeclaration
31+
import com.koresframework.kores.bytecode.BytecodeClass
32+
import com.koresframework.kores.type.`is`
33+
import java.lang.reflect.Type
34+
35+
open class BytecodeCodeClassLoader : ClassLoader {
36+
37+
constructor() : super()
38+
constructor(parent: ClassLoader) : super(parent)
39+
40+
/**
41+
* Define type declaration class.
42+
*
43+
* @param typeDeclaration Type declaration.
44+
* @param bytes Bytes.
45+
* @return Defined Class.
46+
*/
47+
open fun define(typeDeclaration: TypeDeclaration, bytes: ByteArray): Class<*> {
48+
return super.defineClass(typeDeclaration.type, bytes, 0, bytes.size)
49+
}
50+
51+
/**
52+
* Define [BytecodeClass] class.
53+
*
54+
* @param bytecodeClass Bytecode class.
55+
* @return Defined Class.
56+
*/
57+
open fun define(bytecodeClass: BytecodeClass): Class<*> {
58+
val type = (bytecodeClass.declaration as? TypeDeclaration)
59+
?: throw IllegalArgumentException("Non-TypeDeclaration loading is not supported yet. BytecodeClass: $bytecodeClass")
60+
61+
return this.define(type, bytecodeClass.bytecode)
62+
}
63+
64+
/**
65+
* Define [classes][BytecodeClass] and inner classes.
66+
*
67+
* Make sure that all elements in the `bytecodeClasses` is a inner type of first element.
68+
*
69+
* @param bytecodeClasses Bytecode class (first element) and inner classes (remaining).
70+
* @return First Defined Class.
71+
*/
72+
open fun define(bytecodeClasses: Array<out BytecodeClass>): Class<*> {
73+
return this.define(bytecodeClasses.iterator())
74+
}
75+
76+
/**
77+
* Define [classes][BytecodeClass] and inner classes.
78+
*
79+
* Make sure that all elements in the `bytecodeClasses` is a inner type of first element.
80+
*
81+
* @param bytecodeClasses Bytecode class (first element) and inner classes (remaining).
82+
* @return First Defined Class.
83+
*/
84+
open fun define(bytecodeClasses: Collection<BytecodeClass>): Class<*> {
85+
return this.define(bytecodeClasses.iterator())
86+
}
87+
88+
/**
89+
* Define [classes][BytecodeClass] and inner classes.
90+
*
91+
* Make sure that all elements in the `bytecodeClasses` is a inner type of first element.
92+
*
93+
* @param bytecodeClasses Bytecode class (first element) and inner classes (remaining).
94+
* @return First Defined Class.
95+
*/
96+
open fun define(bytecodeClasses: Iterator<BytecodeClass>): Class<*> {
97+
if (!bytecodeClasses.hasNext()) {
98+
throw IllegalArgumentException("Empty 'bytecodeClasses' array")
99+
}
100+
101+
val bytecodeClass = bytecodeClasses.next()
102+
103+
val type = (bytecodeClass.declaration as? TypeDeclaration)
104+
?: throw IllegalArgumentException("Non-TypeDeclaration loading is not supported yet. BytecodeClass: $bytecodeClass")
105+
106+
val define = this.define(type, bytecodeClass.bytecode)
107+
108+
bytecodeClasses.forEach {
109+
this.define(it)
110+
}
111+
112+
return define
113+
}
114+
115+
/**
116+
* Defines very [class][BytecodeClass] in [bytecodeClasses] iterator. All defined
117+
* classes are added to provided [collection].
118+
*
119+
* This function may be used to define inner classes as well as multiple individual classes.
120+
*
121+
* @param bytecodeClasses Bytecode class (first element) and inner classes (remaining).
122+
* @return First Defined Class.
123+
*/
124+
open fun <C: MutableCollection<in LoadedBytecodeClass>> defineEveryTo(
125+
collection: C,
126+
bytecodeClasses: Iterator<BytecodeClass>
127+
): C {
128+
if (!bytecodeClasses.hasNext()) {
129+
throw IllegalArgumentException("Empty 'bytecodeClasses' array")
130+
}
131+
132+
val known = mutableListOf<LoadedBytecodeClass>()
133+
134+
while (bytecodeClasses.hasNext()) {
135+
val bytecodeClass = bytecodeClasses.next()
136+
137+
val type = (bytecodeClass.declaration as? TypeDeclaration)
138+
?: throw IllegalArgumentException("Non-TypeDeclaration loading is not supported yet. BytecodeClass: $bytecodeClass")
139+
140+
val define = this.define(type, bytecodeClass.bytecode)
141+
val outerType = bytecodeClass.declaration.outerType
142+
val outerLazy by lazy {
143+
known.firstOrNull { outerType != null && (it.bytecodeClass.declaration as Type).`is`(outerType) }
144+
}
145+
146+
val loaded = LoadedBytecodeClass(
147+
bytecodeClass,
148+
outerType = { outerLazy },
149+
loadedClass = define
150+
)
151+
152+
collection.add(loaded)
153+
known.add(loaded)
154+
}
155+
156+
return collection
157+
}
158+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Kores-BytecodeWriter - Translates Kores Structure to JVM Bytecode <https://github.com/JonathanxD/CodeAPI-BytecodeWriter>
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <jonathan.scripter@programmer.net>
7+
* Copyright (c) contributors
8+
*
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a copy
11+
* of this software and associated documentation files (the "Software"), to deal
12+
* in the Software without restriction, including without limitation the rights
13+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
* copies of the Software, and to permit persons to whom the Software is
15+
* furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26+
* THE SOFTWARE.
27+
*/
28+
package com.koresframework.kores.bytecode.classloader
29+
30+
import com.koresframework.kores.base.TypeDeclaration
31+
import java.util.*
32+
33+
/**
34+
* Cache all defined classes.
35+
*/
36+
class CachedBytecodeCodeClassLoader : BytecodeCodeClassLoader {
37+
38+
constructor() : super()
39+
constructor(parent: ClassLoader) : super(parent)
40+
41+
private val cache = mutableMapOf<TypeDeclaration, Class<*>>()
42+
private val immutableCache = Collections.unmodifiableMap(cache)
43+
44+
override fun define(typeDeclaration: TypeDeclaration, bytes: ByteArray): Class<*> {
45+
val define = super.define(typeDeclaration, bytes)
46+
47+
this.cache[typeDeclaration] = define
48+
49+
return define
50+
}
51+
52+
fun getCache(): Map<TypeDeclaration, Class<*>> {
53+
return this.immutableCache
54+
}
55+
}

src/main/kotlin/com/github/jonathanxd/kores/bytecode/classloader/CachedCodeClassLoader.kt src/main/kotlin/com/koresframework/kores/bytecode/classloader/CachedCodeClassLoader.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2626
* THE SOFTWARE.
2727
*/
28-
package com.github.jonathanxd.kores.bytecode.classloader
28+
package com.koresframework.kores.bytecode.classloader
2929

30-
import com.github.jonathanxd.kores.base.TypeDeclaration
30+
import com.koresframework.kores.base.TypeDeclaration
3131
import java.util.*
3232

3333
/**

src/main/kotlin/com/github/jonathanxd/kores/bytecode/classloader/ClassInject.kt src/main/kotlin/com/koresframework/kores/bytecode/classloader/ClassInject.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2626
* THE SOFTWARE.
2727
*/
28-
package com.github.jonathanxd.kores.bytecode.classloader
28+
package com.koresframework.kores.bytecode.classloader
2929

30-
import com.github.jonathanxd.kores.base.TypeDeclaration
31-
import com.github.jonathanxd.kores.bytecode.BytecodeClass
30+
import com.koresframework.kores.base.TypeDeclaration
31+
import com.koresframework.kores.bytecode.BytecodeClass
3232

3333
/**
3434
* Class injection utility.
@@ -44,7 +44,7 @@ object ClassInject {
4444
* @return Defined class
4545
* @throws IllegalStateException if the injection fails.
4646
*/
47-
fun ClassLoader.inject(bytecodeClass: com.github.jonathanxd.kores.bytecode.BytecodeClass): Class<*> {
47+
fun ClassLoader.inject(bytecodeClass: com.koresframework.kores.bytecode.BytecodeClass): Class<*> {
4848
val type = (bytecodeClass.declaration as? TypeDeclaration)?.type
4949
?: throw IllegalArgumentException("Non-TypeDeclaration loading is not supported yet. BytecodeClass: $bytecodeClass")
5050

@@ -58,7 +58,7 @@ object ClassInject {
5858
* @return Defined class.
5959
* @throws IllegalStateException if the injection fails or [bytecode classes array][bytecodeClasses] is empty.
6060
*/
61-
fun ClassLoader.inject(bytecodeClasses: Array<out com.github.jonathanxd.kores.bytecode.BytecodeClass>): Class<*> {
61+
fun ClassLoader.inject(bytecodeClasses: Array<out com.koresframework.kores.bytecode.BytecodeClass>): Class<*> {
6262
if (bytecodeClasses.isEmpty()) {
6363
throw IllegalArgumentException("Empty 'bytecodeClasses' array")
6464
}

0 commit comments

Comments
 (0)