Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

2x #19

Open
wants to merge 66 commits into
base: master
Choose a base branch
from
Open

2x #19

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
8e93eed
Update build.gradle
Enaium Sep 22, 2022
d0ba29a
compile
Enaium Sep 22, 2022
1e428a5
fix language
Enaium Sep 29, 2022
d8f7771
Update build.gradle
Enaium Oct 2, 2022
a407de1
Update build.gradle
Enaium Oct 2, 2022
5f402a7
Update build.gradle
Enaium Oct 2, 2022
100f670
Update README.md
Enaium Oct 3, 2022
81acaf5
save text
Enaium Oct 3, 2022
e63e88d
Update TaskManager.java
Enaium Oct 3, 2022
b93e569
message
Enaium Oct 3, 2022
0faf805
Update Dialog.java
Enaium Oct 5, 2022
957fa6b
update asm
Enaium Oct 10, 2022
30f33d9
fix size at high resolution
Enaium Oct 10, 2022
bf4cb13
option
Enaium Oct 10, 2022
e41e927
fix size at high resolution
Enaium Oct 10, 2022
98a984d
add inherit to tab
Enaium Oct 10, 2022
30f168c
Update VerticalLabelUI.java
Enaium Oct 14, 2022
ef2351e
fix font size in high resolution
Enaium Oct 14, 2022
60711a2
fix module class
Enaium Oct 14, 2022
df8d66a
Update CFRDecompiler.java
Enaium Oct 14, 2022
7d87496
edit utils
Enaium Oct 14, 2022
12def6c
decompile and compile
Enaium Oct 14, 2022
c45f8f2
Update CodeAreaPanel.java
Enaium Oct 14, 2022
a008446
i18n
Enaium Oct 14, 2022
8e908fe
tab index consistent
Enaium Oct 14, 2022
6cc4d2f
dialog
Enaium Oct 14, 2022
c39207a
Update Compiler.java
Enaium Oct 14, 2022
a910897
Update build.gradle
Enaium Oct 16, 2022
b5d77a3
classTabIndex
Enaium Oct 16, 2022
469bd33
Update ClassTabPanel.java
Enaium Oct 16, 2022
542c92c
add message
Enaium Oct 16, 2022
95f6134
gson
Enaium Nov 24, 2022
5a383ca
fix integer value
Enaium Nov 24, 2022
1a8d6fb
fix size
Enaium Nov 24, 2022
58a2ec0
add ui scale
Enaium Nov 24, 2022
a7a86e9
flatlaf
Enaium Nov 24, 2022
7119707
version
Enaium Nov 25, 2022
033ff1e
key
Enaium Nov 25, 2022
429b764
key config
Enaium Nov 25, 2022
4f8eb36
layout
Enaium Nov 25, 2022
ea66ba9
key
Enaium Nov 25, 2022
7e95e35
key
Enaium Nov 26, 2022
5e62c9a
2x
Enaium Dec 14, 2022
b82a780
Update Main.kt
Enaium Dec 15, 2022
fbb502e
build
Enaium Dec 15, 2022
999dff2
keycode
Enaium Dec 15, 2022
b48e274
search opcode
Enaium Dec 15, 2022
b9af2b9
jump to node
Enaium Dec 15, 2022
ff6b4fa
optimize
Enaium Dec 15, 2022
94e0597
annotation edit
Enaium Dec 15, 2022
decc5db
window close request
Enaium Dec 16, 2022
ca4ecfa
add tab and select it
Enaium Dec 16, 2022
7277fe2
handle edit
Enaium Dec 16, 2022
a556be0
Update HexPane.kt
Enaium Dec 16, 2022
446a01a
Update ContentTabPane.kt
Enaium Dec 16, 2022
83ee12b
fix control
Enaium Dec 16, 2022
92c019a
label node wrapper
Enaium Dec 16, 2022
248fd5a
optimize
Enaium Dec 16, 2022
488d566
fix control
Enaium Dec 16, 2022
e3e1c78
frame edit
Enaium Dec 16, 2022
a8f9110
optimize
Enaium Dec 16, 2022
6546577
invoke dynamic edit
Enaium Dec 16, 2022
8bd7135
instruction edit
Enaium Dec 16, 2022
7005b5e
optimize
Enaium Dec 16, 2022
b948a69
table switch edit
Enaium Dec 16, 2022
f28cf8c
optimize
Enaium Dec 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
9 changes: 2 additions & 7 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@

![GitHub all releases](https://img.shields.io/github/downloads/Enaium/JavaOctetEditor/total?style=flat-square)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/Enaium/JavaOctetEditor?style=flat-square)
![GitHub](https://img.shields.io/github/license/Enaium/JavaOctetEditor?style=flat-square)

![](https://user-images.githubusercontent.com/32991121/190947407-bbc6642e-2c9d-46f3-921c-6558c74272cf.png)
![](https://user-images.githubusercontent.com/32991121/190947409-9df48d03-e1b7-4c0a-ae1d-08e1ca2bc9aa.png)
![](https://user-images.githubusercontent.com/32991121/190947408-df6c6818-ea79-4a42-8b90-101b6daa3099.png)
![](https://user-images.githubusercontent.com/32991121/190947401-fc08fc4f-3714-49ca-a064-913e7312b191.png)
![](https://user-images.githubusercontent.com/32991121/190947410-4b8f224a-c589-4998-950a-e19618ce5734.png)
![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/Enaium/JavaOctetEditor?include_prereleases&style=flat-square)
![GitHub](https://img.shields.io/github/license/Enaium/JavaOctetEditor?style=flat-square)
90 changes: 19 additions & 71 deletions build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,82 +1,30 @@
import java.text.SimpleDateFormat
import org.gradle.internal.jvm.Jvm

plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'idea'
}

group 'cn.enaium'
version '1.3.0'

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8

jar {
manifest.attributes(
'Manifest-Version': 1.0,
'Main-Class': 'cn.enaium.joe.Main',
"Implementation-Title": "${project.name}",
"Implementation-Version": "${project.version}",
"Implementation-Vendor": "${project.group}",
"Implementation-Timestamp": new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()),
"Premain-Class": "cn.enaium.joe.Agent",
"Agent-Class": "cn.enaium.joe.Agent",
"Can-Redefine-Classes": true,
"Can-Retransform-Classes": true
)
}

new File(System.getProperty("user.dir"), "run").mkdir()

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.quiltmc.org/repository/release' }
allprojects {
group 'cn.enaium'
version '2.0.0'
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
subprojects {
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'

implementation 'com.formdev:flatlaf:2.4'
implementation 'com.formdev:flatlaf-extras:2.4'
//noinspection GradlePackageUpdate
implementation 'com.miglayout:miglayout-swing:5.3'
implementation 'com.github.bobbylight:RSyntaxTextArea:3.2.0'
implementation 'org.ow2.asm:asm-tree:9.3'
implementation 'org.ow2.asm:asm-util:9.3'
implementation 'org.ow2.asm:asm-commons:9.3'
implementation 'org.benf:cfr:0.152'
implementation 'com.github.mstrobel.procyon:procyon-decompiler:v0.6.0'
implementation 'org.quiltmc:quiltflower:1.8.1'
implementation 'org.javassist:javassist:3.29.1-GA'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'org.tinylog:tinylog:1.3.6'
implementation 'com.github.FabricMC:mapping-io:597f0722d6'

compileOnly files(Jvm.current().getToolsJar())//Must use jdk8
}

test {
useJUnitPlatform()
}

shadowJar {
dependencies {
include(dependency('com.formdev:.*'))
include(dependency('com.miglayout:.*'))
include(dependency('com.github.bobbylight:RSyntaxTextArea'))
include(dependency('org.ow2.asm:.*'))
include(dependency('org.benf:cfr'))
include(dependency('com.github.mstrobel.procyon:procyon-decompiler'))
include(dependency('org.javassist:javassist'))
include(dependency('com.google.code.gson:gson'))
include(dependency('org.tinylog:.*'))
include(dependency('org.quiltmc:quiltflower'))
include(dependency('com.github.FabricMC:mapping-io'))
//If you want to use your JDK, just takes to change the JDK version and vendor, otherwise Gradle will be download default JDK
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.BELLSOFT
}
}
archiveClassifier.set('')
}

build.dependsOn shadowJar
repositories {
mavenCentral()
maven { url 'https://maven.quiltmc.org/repository/release' }
maven { url 'https://jitpack.io' }
}
}
19 changes: 19 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'java-library'
}

dependencies {
api 'org.ow2.asm:asm-tree:9.4'
api 'org.ow2.asm:asm-util:9.4'
api 'org.ow2.asm:asm-commons:9.4'
api 'org.benf:cfr:0.152'
api 'com.github.mstrobel.procyon:procyon-decompiler:v0.6.0'
api 'org.quiltmc:quiltflower:1.8.1'
api 'com.google.code.gson:gson:2.10'
api 'org.tinylog:tinylog:1.3.6'
api 'com.github.FabricMC:mapping-io:597f0722d6'
}

test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package cn.enaium.joe.annotation;
package cn.enaium.joe.core.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -23,7 +23,7 @@

/**
* @author Enaium
* @since 0.9.0
* @since 2.0.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package cn.enaium.joe.annotation;
package cn.enaium.joe.core.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -23,7 +23,7 @@

/**
* @author Enaium
* @since 0.9.0
* @since 2.0.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
Expand Down
77 changes: 77 additions & 0 deletions core/src/main/java/cn/enaium/joe/core/compiler/Compiler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright 2022 Enaium
*
* Licensed 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 cn.enaium.joe.core.compiler;

import javax.tools.*;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

/**
* @author Enaium
* @since 2.0.0
*/
public class Compiler {
private final Map<String, VirtualJavaFileObject> javaFileObjectMap = new HashMap<>();

private DiagnosticListener<VirtualJavaFileObject> listener;

public void addSource(String name, String content) {
javaFileObjectMap.put(name, new VirtualJavaFileObject(name, content));
}

public Map<String, byte[]> getClasses() {
return javaFileObjectMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, v -> v.getValue().getBytecode()));
}

@SuppressWarnings("unchecked")
public boolean compile() {
var compiler = ToolProvider.getSystemJavaCompiler();
var fileManager = new VirtualFileManager(compiler.getStandardFileManager(null, null, StandardCharsets.UTF_8));
try {
var task = compiler.getTask(null, fileManager, ((DiagnosticListener<? super JavaFileObject>) (Object) listener), null, null, javaFileObjectMap.values());
Boolean b = task.call();
return b != null && b;
} catch (Exception e) {
return false;
}
}

public void setListener(DiagnosticListener<VirtualJavaFileObject> listener) {
this.listener = listener;
}

private final class VirtualFileManager extends ForwardingJavaFileManager<JavaFileManager> {
public VirtualFileManager(JavaFileManager fileManager) {
super(fileManager);
}

@Override
public JavaFileObject getJavaFileForOutput(Location location, String className, JavaFileObject.Kind kind, FileObject sibling) throws IOException {
if (JavaFileObject.Kind.CLASS == kind) {
VirtualJavaFileObject virtualJavaFileObject = new VirtualJavaFileObject(className, null);
javaFileObjectMap.put(className, virtualJavaFileObject);
return virtualJavaFileObject;
} else {
return super.getJavaFileForOutput(location, className, kind, sibling);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2022 Enaium
*
* Licensed 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 cn.enaium.joe.core.compiler;

import javax.tools.SimpleJavaFileObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URI;

/**
* @author Enaium
* @since 2.0.0
*/
public class VirtualJavaFileObject extends SimpleJavaFileObject {

private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

private final String content;

protected VirtualJavaFileObject(String className, String content) {
super(URI.create("string:///" + className.replace(".", "/") + Kind.SOURCE.extension), Kind.SOURCE);
this.content = content;
}

public byte[] getBytecode() {
return outputStream.toByteArray();
}

@Override
public ByteArrayOutputStream openOutputStream() {
return outputStream;
}

@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
return content;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
* limitations under the License.
*/

package cn.enaium.joe.config;
package cn.enaium.joe.core.config;

/**
* @author Enaium
* @since 0.7.0
* @since 2.0.0
*/
public class Config {
private final String name;

public Config(String name) {
this.name = name;
}
Expand Down
Loading