javap

How to learn about using scala.None from Java using javap?

痞子三分冷 提交于 2019-12-02 13:54:35
In a previous question, Accessing scala.None from Java , it seems that people had used javap to figure out how to access scala.None from Java. I would like to know how they did that. FYI, the answer is: scala.Option$.MODULE$.apply(null); which can be shorted to: scala.Option.apply(null); Given this program ( OptionTest.scala ): object OptionTest extends App { val x = scala.None val y = scala.Some("asdf") } I ran javap on it like this: javap -s -c -l -private OptionTest This is a portion of the javap output: public static final scala.None$ x(); Signature: ()Lscala/None$; Code: 0: getstatic #11;

How do I print the class structures in a jar file using the javap tool?

[亡魂溺海] 提交于 2019-11-30 05:04:57
I want to list the methods of the class files in the jar using the javap tool. How do I do it so that it lists the methods and members of all the class files in the jar. Right now I am able to do it for just one class at a time. I am expecting something like if I say javap java.lang.* it should enlist the methods and members of all the classes in java.lang package. If javap is not capable of that, are there any such tools available? #!/bin/bash # Set the JAR name jar=<JAR NAME> # Loop through the classes (everything ending in .class) for class in $(jar -tf $jar | grep '.class'); do # Replace /

How to use javap with eclipse?

陌路散爱 提交于 2019-11-29 22:29:17
As the title states, I'm trying to use javap with eclipse but have difficulties setting it up. I'm trying to set it up using external tools from the run menu but can't find the correct Arguments: string to make it work. Basically I need something that will dynamically execute the current file I have opened. Vineet Reynolds I use the following external tool configuration to achieve this: ${system_path:javap} is used to locate javap in the JDK used by the Eclipse. You can use an absolute path to javap instead. ${project_loc} returns the absolute path to the project. This is used, since I could

javap and generics' type erasure

£可爱£侵袭症+ 提交于 2019-11-29 07:03:55
I am reading Herbert Schilds about type erasure in generics in java. Supposedly running javap on a class should give me the bytecode information about public, package protected and protected fields and methods after type erasure. However, I wrote the following class: class Ambiguity<T, V extends String>{ T ob1; V ob2; void set(T o){ ob1 = o; } void set(V o){ ob2 = o; } } and ran javap on the class file that was generated and got the following output Compiled from "Test.java" class Ambiguity<T, V extends java.lang.String> { T ob1; V ob2; Ambiguity(); void set(T); void set(V); } I was expecting

How do I print the class structures in a jar file using the javap tool?

半城伤御伤魂 提交于 2019-11-29 02:25:54
问题 I want to list the methods of the class files in the jar using the javap tool. How do I do it so that it lists the methods and members of all the class files in the jar. Right now I am able to do it for just one class at a time. I am expecting something like if I say javap java.lang.* it should enlist the methods and members of all the classes in java.lang package. If javap is not capable of that, are there any such tools available? 回答1: #!/bin/bash # Set the JAR name jar=<JAR NAME> # Loop

Understanding javap's output for the Constant Pool

家住魔仙堡 提交于 2019-11-28 16:25:10
When running javap on a very simple HelloWorld application I have some confusion on the output around the constant pool. Test Code public class TestClass { public static void main(String[] args) { System.out.println("hello world"); } } Javap -c -verbose output (snipped) // Header + consts 1..22 snipped const #22 = String #23; // hello world const #23 = Asciz hello world; public static void main(java.lang.String[]); Signature: ([Ljava/lang/String;)V Code: Stack=2, Locals=1, Args_size=1 0: getstatic #16; //Field java/lang/System.out:Ljava/io/PrintStream; 3: ldc #22; //String hello world 5:

从原理来理解继承关系的类初始化和实例化的顺序

瘦欲@ 提交于 2019-11-28 16:01:50
就像之前的一个评论.我们学习的是思路. 很多人都知道继承关系的类的初始化和实例化的顺序,但如果忘记了怎么办? 如何找到自己的答案? 又如果遇到的问题是关于泛型的擦除问题,又该如何去分析? 思路,重点是思路.泛型擦除先不谈.看继承. 首先给出一个例子,看看它的输出是什么. public class A { private static String a = "NA"; private String i="NA"; { i = "A"; System.out.println(i); } static { a = "Static A"; System.out.println(a); } public A() { System.out.println("Construct A"); } } public class B extends A { private static String b = "NB"; private String j="NB"; { j = "B"; System.out.println(j); } static { b = "Static B"; System.out.println(b); } public B() { System.out.println("Construct B"); } } public class C { public static

javap in a programmable way

我怕爱的太早我们不能终老 提交于 2019-11-28 13:57:48
Can we use javap in our own java code in a programmable way? for example, the following code: public class TestClass { public static void main(String[] args) { System.out.println("hello world"); } } using javap in command line, we got : // Header + consts 1..22 snipped const #22 = String #23; // hello world const #23 = Asciz hello world; public static void main(java.lang.String[]); Signature: ([Ljava/lang/String;)V Code: Stack=2, Locals=1, Args_size=1 0: getstatic #16; //Field java/lang/System.out:Ljava/io/PrintStream; 3: ldc #22; //String hello world 5: invokevirtual #24; //Method java/io

Is there a disassembler + debugger for java (ala OllyDbg / SoftICE for assembler)?

笑着哭i 提交于 2019-11-28 06:29:14
Is there a utility similar to OllyDbg / SoftICE for java? I.e. execute class (from jar / with class path) and, without source code, show the disassembly of the intermediate code with ability to step through / step over / search for references / edit specific intermediate code in memory / apply edit to file... If not, is it even possible to write something like this (assuming we're willing to live without hotspot for the debug duration)? Edit: I'm not talking about JAD or JD or Cavaj. These are fine decompilers, but I don't want a decompiler for several reasons, most notable is that their

javap and generics' type erasure

岁酱吖の 提交于 2019-11-28 00:31:33
问题 I am reading Herbert Schilds about type erasure in generics in java. Supposedly running javap on a class should give me the bytecode information about public, package protected and protected fields and methods after type erasure. However, I wrote the following class: class Ambiguity<T, V extends String>{ T ob1; V ob2; void set(T o){ ob1 = o; } void set(V o){ ob2 = o; } } and ran javap on the class file that was generated and got the following output Compiled from "Test.java" class Ambiguity<T