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

jad cannot just de-compile the method as doc pointed out #208

Closed
1 task done
Hearen opened this issue Oct 10, 2018 · 1 comment
Closed
1 task done

jad cannot just de-compile the method as doc pointed out #208

Hearen opened this issue Oct 10, 2018 · 1 comment

Comments

@Hearen
Copy link
Contributor

Hearen commented Oct 10, 2018

  • I have searched the issues of this repository and believe that this is not a duplicate.

Question

It will decompile the whole class instead of a method addTwoLists.

$ jad demo.Demo addTwoLists

F.Y.I

No answer and details provided in #96

More details provided here to re-produce the issue.

Environment
Arthas version: 3.0.4
Operating System version: 15.6.0 Darwin Kernel Version 15.6.0
Java version of target JVM: jdk1.8.0_73
Java version of JVM used to attach: jdk1.8.0_73

Steps to reproduce this issue

  1. follow this to start Arthas: https://github.com/Hearen/arthas/blob/doc-with-consistent-demo/site/src/site/sphinx/en/quick-start.md
  2. select the demo to monitor
  3. using command sm demo.Demo to ensure addTwoLists exists;
  4. using command jad demo.Demo addTwoLists to decompile the byte code as the jad doc mentioned.

Expected

only method decompiled instead of the whole class as

$ jad demo.Demo addTwoLists

ClassLoader:                                                                                                                                                              
+-sun.misc.Launcher$AppClassLoader@659e0bfd                                                                                                                               
  +-sun.misc.Launcher$ExtClassLoader@6417f14d                                                                                                                             

Location:                                                                                                                                                                 
/Users/lhearen/programs/temp/                                                                                                                                             

/*
 * Decompiled with CFR 0_132.
 */
package demo;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class Demo {
    public static void main(String[] arrstring) throws InterruptedException {
        for (int i = 0; i < 5; ++i) {
            new Thread(() -> {
                try {
                    do {
                        Counter.increment();
                        System.out.println(Thread.currentThread().getName() + " counter: " + Counter.value());
                        Demo.testListAdd();
                        TimeUnit.SECONDS.sleep(5L);
                    } while (true);
                }
                catch (InterruptedException interruptedException) {
                    interruptedException.printStackTrace();
                    return;
                }
            }).start();
        }
    }

    private static synchronized void testListAdd() {
        System.out.println(Thread.currentThread().getName() + " running list add test");
        ArrayList<String> arrayList = new ArrayList<String>();
        arrayList.add("a");
        arrayList.add("b");
        ArrayList<String> arrayList2 = new ArrayList<String>();
        arrayList2.add("c");
        arrayList2.add("d");
        int n = Demo.addTwoLists(arrayList, arrayList2);
    }

    private static synchronized <T> int addTwoLists(List<T> list, List<T> list2) {
        list.addAll(list2);
        return list.size();
    }

    static class Counter {
        private static AtomicInteger count = new AtomicInteger(0);

        Counter() {
        }

        public static synchronized int value() {
            System.out.println("Processing...");
            return count.get();
        }

        public static synchronized void increment() {
            count.incrementAndGet();
        }
    }

}

Affect(row-cnt:2) cost in 772 ms.

@Hearen Hearen changed the title command jad is not working as doc pointed out jad cannot just de-compile the method as doc pointed out Oct 13, 2018
This was referenced Oct 13, 2018
@hengyunabc
Copy link
Collaborator

It works as expected at the master branch. Maybe relate to #302

$ jad demo.Demo addTwoLists

ClassLoader:
+-sun.misc.Launcher$AppClassLoader@659e0bfd
  +-sun.misc.Launcher$ExtClassLoader@2be2e1f7

Location:
/private/tmp/

private static synchronized <T> int addTwoLists(List<T> list, List<T> list2) {
    list.addAll(list2);
    return list.size();
}

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