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

Update Blinky for Java9+ Projects #8

Open
Annette0127 opened this issue Nov 22, 2022 · 5 comments
Open

Update Blinky for Java9+ Projects #8

Annette0127 opened this issue Nov 22, 2022 · 5 comments
Assignees

Comments

@Annette0127
Copy link
Contributor

We want to do is to run Blinky successfully on projects on Java9+ (e.g., Java11).

@Annette0127
Copy link
Contributor Author

Hi Vijay @VijayKrishna, I am Yirui He!

We discussed using ASM7 Java11. According to the issue, it mentioned that asm-debug-all had been removed since ASM6.0. In the Blinky project, the code used the package asm-debug-all for invoking ASM functions. In order to use ASM7.0 instead, I think we need to move to the following packages: asm, asm-tree, asm-util and asm-commons.

Is this change ok?

@Annette0127
Copy link
Contributor Author

Annette0127 commented Dec 4, 2022

Hi Vijay @VijayKrishna,

Hope you are doing well! :)

For now, I adopted Java11 and ASM7.1. And I changed all ASM4 or ASM5 to ASM7, but it still has some problems with working.

There are no exceptions while building the jar or actually running the jar, but it does not have the exact same behavior as the code compiled under Java8. For more details is that it does not have the log after FEEDBACK: Class Retransformation is disabled. This means it does not have logs indicating whether the instrumentation is successful or skipped.

Here are some details I found for the inconsistencies using OfflineInstrumenter in blinky-core. I was wondering if you have any suggestion of which part of the code I could specifically look at to solve this problem.

Sample code to instrument:

public static void main(String[] args) {
        print233();
    }
    public static void print233() {
        System.out.println("233");
    }
}

The difference between the two instrumentation results is the number of instrumented instructions and the content of instruction and tag for all instructions. Details are as follows:

Decompile the instrumented code of Java-8 version:

public static void main(String[] var0) {
        TraceLogger.probleWillStart();
        Profiler.printLnArgLog("[Ljava/lang/String;", "0", (boolean)1, (boolean)1);
        TraceLogger.probleWillStart();
        Profiler.printLnMethodEnterLog("hyr/blinky/Main", "main([Ljava/lang/String;)V", "-13", "C");
        TraceLogger.probleWillStart();
        Profiler.printLnLineNumber("-14", "C");
        TraceLogger.probleWillStart();
        Profiler.printlnInvokeLog("-15", "C");
        print233();
        TraceLogger.probleWillStart();
        Profiler.printlnCompleteLog("-16", "C");
        TraceLogger.probleWillStart();
        Profiler.printLnLineNumber("-17", "C");
        TraceLogger.probleWillStart();
        Profiler.printLnMethodExitLog("hyr/blinky/Main", "main([Ljava/lang/String;)V", "-18", "C");
    }
    public static void print233() {
        TraceLogger.probleWillStart();
        Profiler.printLnMethodEnterLog("hyr/blinky/Main", "print233()V", "-19", "C");
        TraceLogger.probleWillStart();
        Profiler.printLnLineNumber("-20", "C");
        TraceLogger.probleWillStart();
        PrintStream var10000 = System.out;
        Profiler.printlnField("java/lang/System", "0", "-21", "C");
        TraceLogger.probleWillStart();
        Profiler.printlnConstantLog("-22", "C");
        TraceLogger.probleWillStart();
        Profiler.printlnInvokeLog("-23", "C");
        var10000.println("233");
        TraceLogger.probleWillStart();
        Profiler.printlnCompleteLog("-24", "C");
        TraceLogger.probleWillStart();
        Profiler.printLnLineNumber("-25", "C");
        TraceLogger.probleWillStart();
        Profiler.printLnMethodExitLog("hyr/blinky/Main", "print233()V", "-26", "C");
    }

Decompile the instrumented code of Java-11 version:

public static void main(String[] var0) {
        TraceLogger.probleWillStart();
        Profiler.printLnArgLog("[Ljava/lang/String;", "0", (boolean)1, (boolean)1);
        TraceLogger.probleWillStart();
        Profiler.printLnMethodEnterLog("hyr/blinky/Main", "main([Ljava/lang/String;)V", "-11", "C");
        TraceLogger.probleWillStart();
        Profiler.printLnLineNumber("-12", "C");
        print233();
        TraceLogger.probleWillStart();
        Profiler.printLnLineNumber("-13", "C");
        TraceLogger.probleWillStart();
        Profiler.printLnMethodExitLog("hyr/blinky/Main", "main([Ljava/lang/String;)V", "-14", "C");
    }
    public static void print233() {
        TraceLogger.probleWillStart();
        Profiler.printLnMethodEnterLog("hyr/blinky/Main", "print233()V", "-15", "C");
        TraceLogger.probleWillStart();
        Profiler.printLnLineNumber("-16", "C");
        TraceLogger.probleWillStart();
        PrintStream var10000 = System.out;
        Profiler.printlnField("java/lang/System", "0", "-17", "C");
        TraceLogger.probleWillStart();
        Profiler.printlnConstantLog("-18", "C");
        var10000.println("233");
        TraceLogger.probleWillStart();
        Profiler.printLnLineNumber("-19", "C");
        TraceLogger.probleWillStart();
        Profiler.printLnMethodExitLog("hyr/blinky/Main", "print233()V", "-20", "C");
    }

For the Profiler, I used the provided example called CallGrapthGenerator, and changed the following two methods:

@Override
	public void profileMethodEntry(final TraceEvent e) {
		REAL_OUT.print("profileMethodEntry ");
		Thread.dumpStack();
		REAL_OUT.print(" " + e.getInsnFieldName());
		REAL_OUT.print(" " + e.getDeclName());
		REAL_OUT.print(" " + e.getLog());
		REAL_OUT.print(" " + e.getType());
		REAL_OUT.print("  " + e.getExecInsnType());
		REAL_OUT.print("  EventId=" + e.getExecInsnEventId());
		REAL_OUT.print(" Calldepth=" + e.getExecCalldepth());
		REAL_OUT.println(" Timestamp=" + e.getExecTimestamp());
	}
	@Override
	public void profileMethodExit(final TraceEvent e) {
		REAL_OUT.print("profileMethodExit ");
		Thread.dumpStack();
		REAL_OUT.print(" " + e.getInsnFieldName());
		REAL_OUT.print(" " + e.getDeclName());
		REAL_OUT.print(" " + e.getLog());
		REAL_OUT.print(" " + e.getType());
		REAL_OUT.print("  " + e.getExecInsnType());
		REAL_OUT.print("  EventId=" + e.getExecInsnEventId());
		REAL_OUT.print(" Calldepth=" + e.getExecCalldepth());
		REAL_OUT.println(" Timestamp=" + e.getExecTimestamp());
	}

@VijayKrishna VijayKrishna self-assigned this Dec 4, 2022
@VijayKrishna
Copy link
Member

@Annette0127 ack.

@Annette0127
Copy link
Contributor Author

Hi Vijay @VijayKrishna, happy new year! Wish you had a good winter vacation!😊

I was wondering if you had a chance to look at this issue. If there are any fixes or hints/suggestions for me to fix the issue, please let me know. I would like to help to fix this! If you think it would be more helpful to have a meeting over zoom, we can also schedule one.

@Annette0127
Copy link
Contributor Author

Hi Vijay @VijayKrishna, this is the zip file of the Blinky. (Since GitHub does not support uploading jar files 😅)

blinky-core-0.0.1-SNAPSHOT-jar-with-dependencies.jar.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants