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

4x: Added new JASM 2.0 #722

Merged
merged 60 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
3c37aa5
Add jasm as depend
jumanji144 Sep 15, 2023
d94266c
Basic jasm implementation
jumanji144 Sep 21, 2023
f6c61f1
Basic jasm compiling
jumanji144 Sep 21, 2023
13eddf2
Change over to remote maven
jumanji144 Sep 21, 2023
92cb925
Add better parsing wait
jumanji144 Sep 21, 2023
83d0243
Update JASM to 2.0.0.1
jumanji144 Sep 24, 2023
ac2e5f5
Merge remote-tracking branch 'origin/dev4' into assembler
jumanji144 Sep 24, 2023
06aaea2
Update jasm to 2.0.1
jumanji144 Sep 26, 2023
82731d2
Merge remote-tracking branch 'origin/dev4' into assembler
jumanji144 Sep 26, 2023
b8c5f22
Merge remote-tracking branch 'origin/dev4' into assembler
jumanji144 Sep 26, 2023
b9dc5cc
Merge branch 'dev4' of https://github.com/Col-E/Recaf into pr/722
Col-E Oct 21, 2023
8db6785
Add assembler config lang entries
Col-E Oct 21, 2023
7ce0817
Cleanup jvm class builder usage to remove redundant 'new ClassReader'
Col-E Oct 21, 2023
460580a
Add utils for creating new member predicates
Col-E Oct 21, 2023
05cdfff
Cleanup field/method context menu edit entries
Col-E Oct 21, 2023
cf129ee
Add some jasm keywords
Col-E Oct 21, 2023
8e28728
Handle runtime errors from JPhantom
Col-E Oct 21, 2023
8e00687
Document assembler pipeline types
Col-E Oct 21, 2023
96a18ab
Support block indent with TAB/SHIFT-TAB
Col-E Oct 22, 2023
8fad67a
Add extra JFX validation exit codes for min supported versions
Col-E Oct 22, 2023
c7b0530
Bit of docs/cleanup in assembler pane, update Jasm to fix shuffled me…
Col-E Oct 22, 2023
f48acfa
Support auto-indent. New lines match indentation of prior lines. Brac…
Col-E Oct 23, 2023
d926653
Basics of tab completion
Col-E Oct 23, 2023
1de15bb
Fix selected text + newline pressed not overwriting selected text
Col-E Oct 26, 2023
643d30d
Flesh out tab completion API a bit more
Col-E Oct 26, 2023
07664ac
Merge branch 'dev4' into pr/722
Col-E Oct 27, 2023
604b9f9
Alternative approach to excluding JFX from output with JFX plugin 0.1.0
Col-E Oct 27, 2023
dd1d93c
Merge branch 'dev4' into pr/722
Col-E Oct 27, 2023
54d4cf7
Fix loading modules files not reading correct paths
Col-E Nov 14, 2023
60f5401
Update cafedude to 2.0.0
Col-E Nov 14, 2023
614f617
Fix opening new workspaces glitching out the UI thread
Col-E Nov 14, 2023
9ed2a4a
Tweaks to pipeline assemble flow
Col-E Nov 15, 2023
b4df6c2
Fix JVM assembler pipeline emitting wrong class version
Col-E Nov 15, 2023
8b9f8fa
Start of analysis work in the assembler gui
Col-E Nov 15, 2023
a808528
Gracefully handle OpenRewrite failures in AST mapping process
Col-E Nov 22, 2023
c514be8
Add new menu-builder helper system which allows for external control …
Col-E Nov 28, 2023
5d0c67c
Create basic whitelist/blacklist context sources
Col-E Nov 30, 2023
f1a9a03
Implement variables pane click-to-navigate
Col-E Nov 30, 2023
e783e8e
Update empty line handling in style configs
Col-E Nov 30, 2023
5e0cf57
Force US locale
Col-E Dec 8, 2023
885539a
Create stack analysis panel implementation
Col-E Dec 8, 2023
c4b64a4
Bump JFX to 22, should resolve launch crashes on MacOS 14
Col-E Dec 11, 2023
e935f2a
Add more jasm keywords
Col-E Dec 11, 2023
6a92fec
Make ClassNavigable define its own ClassPathNode getter, rather than …
Col-E Dec 11, 2023
6855332
Skip assemble if there are problem OR no concrete AST was made
Col-E Dec 11, 2023
51a460b
Additional utility method on PathNode for operating on types/values f…
Col-E Dec 11, 2023
fe3a1f6
Ensure assembler tabs do not prevent normal navigation to classes
Col-E Dec 13, 2023
3d4f810
Fix tab-completion breaking mutli-key action like CTRL-Z
Col-E Dec 13, 2023
e67f619
Class level assembler support for stack/variable analysis
Col-E Dec 13, 2023
ef7cc3b
Bump Cafedude version -> 2.0.1
Col-E Dec 16, 2023
bee4903
Make side-tabs usable horizontally as well
Col-E Dec 16, 2023
374d261
Update Null post-processing plugin
Col-E Jan 6, 2024
6468d4e
Improve CDI event handling for startup tasks
Col-E Jan 6, 2024
8c28a47
Path node documentation cleanup
Col-E Jan 6, 2024
cb7952a
Skip BaseDirectories usage on Windows, direct APPDATA lookup is faste…
Col-E Jan 6, 2024
c4ddfdd
Basis for assembler context resolving / menu creation
Col-E Jan 6, 2024
c5b3c62
Merge branch 'dev4' into assembler
Col-E Jan 6, 2024
d95e8d9
Basic assembler context menu implementations, with some content types…
Col-E Jan 7, 2024
875e3ee
Fix assembler warn not running on FX thread
Col-E Jan 7, 2024
b5ebc67
Fix compiler warnings for table-view column population
Col-E Jan 7, 2024
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'com.github.ben-manes.versions' version '0.42.0' apply false
id 'gov.tak.gradle.plugins.coverage-report-aggregator' version '1.3.0'
id 'gov.tak.gradle.plugins.checker-processor' version '2.0.1' apply false
id 'gov.tak.gradle.plugins.checker-processor' version '2.0.2' apply false
}

allprojects {
Expand Down
10 changes: 7 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
def asmVersion = '9.6'
def cafeDudeVersion = '1.10.2'
def cafeDudeVersion = '2.0.1'
def junitVersion = '5.10.0'
def jasmVersion = '2.3.0'

project.ext {
asm = "org.ow2.asm:asm:$asmVersion"
Expand All @@ -14,7 +15,7 @@ project.ext {

atlantafx = 'io.github.mkpaz:atlantafx-base:2.0.1'

cafedude = "com.github.Col-E:CAFED00D:$cafeDudeVersion"
cafedude = "software.coley:cafedude-core:$cafeDudeVersion"

cfr = 'org.benf:cfr:0.152'

Expand All @@ -38,6 +39,9 @@ project.ext {

instrument_server = 'software.coley:instrumentation-server:1.4.0'

jasm_core = "com.github.Nowilltolife.Jasm:jasm-core:$jasmVersion"
jasm_composistion_jvm = "com.github.Nowilltolife.Jasm:jasm-composition-jvm:$jasmVersion"

jackson = 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.15.2'

jlinker = 'com.github.xxDark:jlinker:1.0.7'
Expand All @@ -62,7 +66,7 @@ project.ext {

regex = 'com.github.tommyettinger:regexodus:0.1.15'

richtextfx = 'org.fxmisc.richtext:richtextfx:0.11.1'
richtextfx = 'org.fxmisc.richtext:richtextfx:0.11.2'

treemapfx = 'software.coley:treemap-fx:1.1.0'
}
2 changes: 2 additions & 0 deletions recaf-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ dependencies {
api jlinker
api openrewrite
api regex
api jasm_core
api jasm_composistion_jvm
}

// Force generation of gversion data class when the version information is not up-to-date
Expand Down
6 changes: 5 additions & 1 deletion recaf-core/src/main/java/software/coley/recaf/Bootstrap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package software.coley.recaf;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import jakarta.enterprise.inject.se.SeContainer;
import org.jboss.weld.environment.se.Weld;
import org.slf4j.Logger;
Expand All @@ -23,6 +25,7 @@ public class Bootstrap {
/**
* @return Recaf instance.
*/
@Nonnull
public static Recaf get() {
if (instance == null) {
logger.info("Initializing Recaf {}", RecafBuildConfig.VERSION);
Expand All @@ -42,10 +45,11 @@ public static Recaf get() {
* @param consumer
* Consumer to operate on the CDI container producing {@link Weld} instance.
*/
public static void setWeldConsumer(Consumer<Weld> consumer) {
public static void setWeldConsumer(@Nullable Consumer<Weld> consumer) {
weldConsumer = consumer;
}

@Nonnull
private static SeContainer createContainer() {
logger.info("Creating Recaf CDI container...");
Weld weld = new Weld("recaf");
Expand Down
13 changes: 7 additions & 6 deletions recaf-core/src/main/java/software/coley/recaf/Recaf.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package software.coley.recaf;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.spi.Context;
import jakarta.enterprise.context.spi.CreationalContext;
import jakarta.enterprise.inject.Instance;
import jakarta.enterprise.inject.se.SeContainer;
import jakarta.enterprise.inject.spi.Bean;
import jakarta.enterprise.inject.spi.BeanContainer;
import software.coley.recaf.cdi.WorkspaceBeanContext;
import software.coley.recaf.workspace.WorkspaceManager;

import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Set;
import java.util.Locale;

/**
* Recaf application instance.
Expand Down Expand Up @@ -105,4 +100,10 @@ public <T> T get(@Nonnull Class<T> type) {
public <T> T get(@Nonnull Class<T> type, Annotation... qualifiers) {
return instance(type, qualifiers).get();
}

static {
// Enforce US locale just in case we have some string formatting susceptible to this "feature":
// https://mattryall.net/blog/the-infamous-turkish-locale-bug
Locale.setDefault(Locale.US);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package software.coley.recaf.cdi;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.spi.*;
import jakarta.enterprise.inject.spi.Annotated;
import jakarta.enterprise.inject.spi.Bean;
import jakarta.enterprise.inject.spi.BeanManager;
import jakarta.enterprise.inject.spi.Extension;
import jakarta.enterprise.inject.spi.ProcessBean;
import jakarta.inject.Inject;
import software.coley.recaf.workspace.model.Workspace;

Expand All @@ -18,7 +23,7 @@
*/
public class EagerInitializationExtension implements Extension {
private static final EagerInitializationExtension INSTANCE = new EagerInitializationExtension();
private static final List<Bean<?>> applicationScopedEagerBeansForDeploy = new ArrayList<>();
private static final List<Bean<?>> applicationScopedEagerBeans = new ArrayList<>();
private static final List<Bean<?>> applicationScopedEagerBeansForUi = new ArrayList<>();
private static final List<Bean<?>> workspaceScopedEagerBeans = new ArrayList<>();
private static BeanManager beanManager;
Expand All @@ -29,20 +34,31 @@ private EagerInitializationExtension() {
/**
* @return Extension singleton.
*/
@Nonnull
public static EagerInitializationExtension getInstance() {
return INSTANCE;
}

/**
* @return Application scoped {@link EagerInitialization} beans.
*/
public static List<Bean<?>> getApplicationScopedEagerBeansForDeploy() {
return applicationScopedEagerBeansForDeploy;
@Nonnull
public static List<Bean<?>> getApplicationScopedEagerBeans() {
return applicationScopedEagerBeans;
}

/**
* @return Application scoped {@link EagerInitialization} beans which will wait for the UI to be initialized before being initialized.
*/
@Nonnull
public static List<Bean<?>> getApplicationScopedEagerBeansForUi() {
return applicationScopedEagerBeansForUi;
}

/**
* @return Workspace scoped {@link EagerInitialization} beans.
*/
@Nonnull
public static List<Bean<?>> getWorkspaceScopedEagerBeans() {
return workspaceScopedEagerBeans;
}
Expand All @@ -60,7 +76,7 @@ public void onProcessBean(@Observes ProcessBean<?> event) {
if (eager != null) {
if (annotated.isAnnotationPresent(ApplicationScoped.class)) {
if (eager.value() == InitializationStage.IMMEDIATE)
applicationScopedEagerBeansForDeploy.add(event.getBean());
applicationScopedEagerBeans.add(event.getBean());
else if (eager.value() == InitializationStage.AFTER_UI_INIT)
applicationScopedEagerBeansForUi.add(event.getBean());
} else if (annotated.isAnnotationPresent(WorkspaceScoped.class))
Expand All @@ -69,16 +85,16 @@ else if (eager.value() == InitializationStage.AFTER_UI_INIT)
}

/**
* Called when the CDI container deploys.
* Called when Recaf initializes the CDI container, and after plugins are loaded.
*
* @param event
* CDI deploy event.
* Recaf initialization event.
* @param beanManager
* CDI bean manager.
*/
public void onDeploy(@Observes AfterDeploymentValidation event, BeanManager beanManager) {
public void onInitialize(@Observes InitializationEvent event, @Nonnull BeanManager beanManager) {
EagerInitializationExtension.beanManager = beanManager;
for (Bean<?> bean : applicationScopedEagerBeansForDeploy)
for (Bean<?> bean : applicationScopedEagerBeans)
create(bean);
}

Expand All @@ -91,7 +107,7 @@ public void onDeploy(@Observes AfterDeploymentValidation event, BeanManager bean
* @param beanManager
* CDI bean manager.
*/
public void onUiInitialize(@Observes UiInitializationEvent event, BeanManager beanManager) {
public void onUiInitialize(@Observes UiInitializationEvent event, @Nonnull BeanManager beanManager) {
EagerInitializationExtension.beanManager = beanManager;
for (Bean<?> bean : applicationScopedEagerBeansForUi)
create(bean);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package software.coley.recaf.cdi;

/**
* Empty type, used to notify CDI consumers observing this type that the application has been launched.
*
* @author Matt Coley
* @see UiInitializationEvent Alternative which waits for the UI to initialize.
*/
public class InitializationEvent {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Empty type, used to notify CDI consumers observing this type that the UI has been populated.
*
* @author Matt Coley
* @see InitializationEvent Alternative which runs before the UI is initialized.
*/
public class UiInitializationEvent {
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public final class ConfigGroups {
* Group for analyzing components.
*/
public static final String SERVICE_ANALYSIS = SERVICE + PACKAGE_SPLIT + "analysis";
/**
* Group for assembler components.
*/
public static final String SERVICE_ASSEMBLER = SERVICE + PACKAGE_SPLIT + "assembler";
/**
* Group for compiler components.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package software.coley.recaf.info;

import jakarta.annotation.Nonnull;
import me.coley.cafedude.classfile.ConstantPoolConstants;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Type;
import software.coley.cafedude.classfile.ConstantPoolConstants;
import software.coley.recaf.info.builder.JvmClassInfoBuilder;
import software.coley.recaf.util.Types;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package software.coley.recaf.launch;

import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;
import software.coley.recaf.cdi.EagerInitialization;
import software.coley.recaf.cdi.InitializationStage;

/**
* A special {@link EagerInitialization eagerly initialized bean} wrapper of {@link Runnable} which is specially by
* the entry-point of the program. The lack of the {@link EagerInitialization} annotation on this type is intentional
* as the entry-point determines if it should be run with {@link InitializationStage#IMMEDIATE} or
* {@link InitializationStage#AFTER_UI_INIT} dynamically.
*
* @author Matt Coley
*/
@ApplicationScoped
public class LaunchHandler {
/**
* Task to execute.
*/
public static Runnable task;

@PostConstruct
private void run() {
if (task != null)
task.run();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ public PathNode<P> getParent() {
return parent;
}

@Nullable
@Override
@SuppressWarnings("unchecked")
public <T, I extends PathNode<T>> I getParentOfType(@Nonnull Class<T> type) {
if (getValueType().isAssignableFrom(type))
return (I) this;
if (parent == null) return null;
return parent.getParentOfType(type);
}

@Nonnull
@Override
public String typeId() {
Expand All @@ -113,15 +103,6 @@ public Class<V> getValueType() {
return valueType;
}

@Override
@SuppressWarnings("unchecked")
public <T> T getValueOfType(@Nonnull Class<T> type) {
if (getValueType().isAssignableFrom(type))
return (T) getValue();
if (parent == null) return null;
return parent.getValueOfType(type);
}

@Nonnull
@Override
@SuppressWarnings("all")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import software.coley.recaf.info.InnerClassInfo;
import software.coley.recaf.info.annotation.Annotated;
import software.coley.recaf.info.annotation.AnnotationInfo;

import java.util.Set;

/**
* Path node for annotations on {@link Annotated} types such as classes, fields, and methods..
* Path node for annotations on {@link Annotated} types such as classes, fields, and methods.
*
* @author Matt Coley
*/
Expand Down Expand Up @@ -40,6 +39,7 @@ public AnnotationPathNode(@Nonnull AnnotationInfo annotation) {
* @see ClassMemberPathNode#childAnnotation(AnnotationInfo)
* @see ClassPathNode#child(AnnotationInfo)
* @see AnnotationPathNode#child(AnnotationInfo)
* @see InnerClassPathNode#child(AnnotationInfo)
*/
@SuppressWarnings("unchecked")
public AnnotationPathNode(@Nullable PathNode<?> parent, @Nonnull AnnotationInfo annotation) {
Expand All @@ -50,7 +50,7 @@ public AnnotationPathNode(@Nullable PathNode<?> parent, @Nonnull AnnotationInfo
* @param annotation
* Annotation to wrap into node.
*
* @return Path node of annotation, with current annotation as parent.
* @return Path node of annotation, with the current annotation as parent.
*/
@Nonnull
public AnnotationPathNode child(@Nonnull AnnotationInfo annotation) {
Expand All @@ -60,7 +60,7 @@ public AnnotationPathNode child(@Nonnull AnnotationInfo annotation) {
@Nonnull
@Override
public Set<String> directParentTypeIds() {
return Set.of(ClassPathNode.TYPE_ID, ClassMemberPathNode.TYPE_ID, AnnotationPathNode.TYPE_ID);
return Set.of(ClassPathNode.TYPE_ID, ClassMemberPathNode.TYPE_ID, InnerClassPathNode.TYPE_ID, AnnotationPathNode.TYPE_ID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public BundlePathNode(@Nullable ResourcePathNode parent, @Nonnull Bundle<?> bund
* @param directory
* Directory to wrap in path node.
*
* @return Path node of directory, with current bundle as parent.
* @return Path node of directory, with the current bundle as parent.
*/
@Nonnull
public DirectoryPathNode child(@Nullable String directory) {
Expand Down
Loading