JPad
Snippets
Download
Help
Contact
DumpClass-example
Example implementation of a DumpClass helper to show reflection properties available in the absence of Intellisense.
Code
public static void main(String[] args) { Pattern p = Pattern.compile("[a-z]"); DumpClass(Pattern.class); Matcher m = p.matcher("f"); DumpClass(m); Dump(m); } public static void DumpClass(Object o) { DumpClass(o.getClass()); } public static void DumpClass(Class c) { System.out.println("--Class " + c.getTypeName() + "--"); for (java.lang.reflect.Method m : c.getMethods()) { Class rt = m.getReturnType(); Class[] pt = m.getParameterTypes(); System.out.print("\t" + rt.getName() + " " + m.getName() + "("); for (java.lang.Class ct : pt) { System.out.print(ct.getName() + ","); } System.out.println(")"); } System.out.println(); }
Result
Console
--Class java.util.regex.Pattern-- java.lang.String toString() int flags() java.util.regex.Pattern compile(java.lang.String,) java.util.regex.Pattern compile(java.lang.String,int,) java.util.regex.Matcher matcher(java.lang.CharSequence,) boolean matches(java.lang.String,java.lang.CharSequence,) [Ljava.lang.String; split(java.lang.CharSequence,int,) [Ljava.lang.String; split(java.lang.CharSequence,) java.lang.String quote(java.lang.String,) java.util.function.Predicate asPredicate() java.lang.String pattern() java.util.stream.Stream splitAsStream(java.lang.CharSequence,) void wait() void wait(long,int,) void wait(long,) boolean equals(java.lang.Object,) int hashCode() java.lang.Class getClass() void notify() void notifyAll() --Class java.util.regex.Matcher-- int end(java.lang.String,) int end() int end(int,) java.lang.String group(java.lang.String,) java.lang.String group(int,) java.lang.String group() java.lang.String toString() boolean matches() java.lang.String quoteReplacement(java.lang.String,) java.lang.String replaceAll(java.lang.String,) java.lang.String replaceFirst(java.lang.String,) boolean find(int,) boolean find() int start() int start(int,) int start(java.lang.String,) java.util.regex.Matcher reset() java.util.regex.Matcher reset(java.lang.CharSequence,) java.util.regex.Matcher appendReplacement(java.lang.StringBuffer,java.lang.String,) java.lang.StringBuffer appendTail(java.lang.StringBuffer,) java.util.regex.Matcher region(int,int,) java.util.regex.Pattern pattern() boolean hitEnd() int groupCount() boolean hasAnchoringBounds() boolean hasTransparentBounds() boolean lookingAt() int regionEnd() int regionStart() boolean requireEnd() java.util.regex.MatchResult toMatchResult() java.util.regex.Matcher useAnchoringBounds(boolean,) java.util.regex.Matcher usePattern(java.util.regex.Pattern,) java.util.regex.Matcher useTransparentBounds(boolean,) void wait() void wait(long,int,) void wait(long,) boolean equals(java.lang.Object,) int hashCode() java.lang.Class getClass() void notify() void notifyAll() java.util.regex.Matcher[pattern=[a-z] region=0,1 lastmatch=]
Bytecode
Compiled from "RunnContainer.java" public class io.jpad.scratch.RunnContainer { public io.jpad.scratch.RunnContainer(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object."<init>":()V 4: return public static void main(java.lang.String[]); Code: 0: ldc #2 // String [a-z] 2: invokestatic #3 // Method java/util/regex/Pattern.compile:(Ljava/lang/String;)Ljava/util/regex/Pattern; 5: astore_1 6: ldc #4 // class java/util/regex/Pattern 8: invokestatic #5 // Method DumpClass:(Ljava/lang/Class;)V 11: aload_1 12: ldc #6 // String f 14: invokevirtual #7 // Method java/util/regex/Pattern.matcher:(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher; 17: astore_2 18: aload_2 19: invokestatic #8 // Method DumpClass:(Ljava/lang/Object;)V 22: aload_2 23: invokestatic #9 // Method io/jpad/scratch/Dumper.Dump:(Ljava/lang/Object;)Ljava/lang/Object; 26: pop 27: return public static void DumpClass(java.lang.Object); Code: 0: aload_0 1: invokevirtual #10 // Method java/lang/Object.getClass:()Ljava/lang/Class; 4: invokestatic #5 // Method DumpClass:(Ljava/lang/Class;)V 7: return public static void DumpClass(java.lang.Class); Code: 0: getstatic #11 // Field java/lang/System.out:Ljava/io/PrintStream; 3: new #12 // class java/lang/StringBuilder 6: dup 7: invokespecial #13 // Method java/lang/StringBuilder."<init>":()V 10: ldc #14 // String --Class 12: invokevirtual #15 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 15: aload_0 16: invokevirtual #16 // Method java/lang/Class.getTypeName:()Ljava/lang/String; 19: invokevirtual #15 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 22: ldc #17 // String -- 24: invokevirtual #15 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 27: invokevirtual #18 // Method java/lang/StringBuilder.toString:()Ljava/lang/String; 30: invokevirtual #19 // Method java/io/PrintStream.println:(Ljava/lang/String;)V 33: aload_0 34: invokevirtual #20 // Method java/lang/Class.getMethods:()[Ljava/lang/reflect/Method; 37: astore_1 38: aload_1 39: arraylength 40: istore_2 41: iconst_0 42: istore_3 43: iload_3 44: iload_2 45: if_icmpge 189 48: aload_1 49: iload_3 50: aaload 51: astore 4 53: aload 4 55: invokevirtual #21 // Method java/lang/reflect/Method.getReturnType:()Ljava/lang/Class; 58: astore 5 60: aload 4 62: invokevirtual #22 // Method java/lang/reflect/Method.getParameterTypes:()[Ljava/lang/Class; 65: astore 6 67: getstatic #11 // Field java/lang/System.out:Ljava/io/PrintStream; 70: new #12 // class java/lang/StringBuilder 73: dup 74: invokespecial #13 // Method java/lang/StringBuilder."<init>":()V 77: ldc #23 // String \t 79: invokevirtual #15 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 82: aload 5 84: invokevirtual #24 // Method java/lang/Class.getName:()Ljava/lang/String; 87: invokevirtual #15 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 90: ldc #25 // String 92: invokevirtual #15 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 95: aload 4 97: invokevirtual #26 // Method java/lang/reflect/Method.getName:()Ljava/lang/String; 100: invokevirtual #15 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 103: ldc #27 // String ( 105: invokevirtual #15 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 108: invokevirtual #18 // Method java/lang/StringBuilder.toString:()Ljava/lang/String; 111: invokevirtual #28 // Method java/io/PrintStream.print:(Ljava/lang/String;)V 114: aload 6 116: astore 7 118: aload 7 120: arraylength 121: istore 8 123: iconst_0 124: istore 9 126: iload 9 128: iload 8 130: if_icmpge 175 133: aload 7 135: iload 9 137: aaload 138: astore 10 140: getstatic #11 // Field java/lang/System.out:Ljava/io/PrintStream; 143: new #12 // class java/lang/StringBuilder 146: dup 147: invokespecial #13 // Method java/lang/StringBuilder."<init>":()V 150: aload 10 152: invokevirtual #24 // Method java/lang/Class.getName:()Ljava/lang/String; 155: invokevirtual #15 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 158: ldc #29 // String , 160: invokevirtual #15 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 163: invokevirtual #18 // Method java/lang/StringBuilder.toString:()Ljava/lang/String; 166: invokevirtual #28 // Method java/io/PrintStream.print:(Ljava/lang/String;)V 169: iinc 9, 1 172: goto 126 175: getstatic #11 // Field java/lang/System.out:Ljava/io/PrintStream; 178: ldc #30 // String ) 180: invokevirtual #19 // Method java/io/PrintStream.println:(Ljava/lang/String;)V 183: iinc 3, 1 186: goto 43 189: getstatic #11 // Field java/lang/System.out:Ljava/io/PrintStream; 192: invokevirtual #31 // Method java/io/PrintStream.println:()V 195: return }
Jpad Version:1.05
viewCount:3308
Creator:
mellamokb
Latest Editor:
mellamokb
Tags
java
dumpclass
Download
Copy As Markdown:
**code [DumpClass-example.java](/example/1v/dumpclass-example)** public static void main(String[] args) { Pattern p = Pattern.compile("[a-z]"); DumpClass(Pattern.class); Matcher m = p.matcher("f"); DumpClass(m); Dump(m); } public static void DumpClass(Object o) { DumpClass(o.getClass()); } public static void DumpClass(Class c) { System.out.println("--Class " + c.getTypeName() + "--"); for (java.lang.reflect.Method m : c.getMethods()) { Class rt = m.getReturnType(); Class[] pt = m.getParameterTypes(); System.out.print("\t" + rt.getName() + " " + m.getName() + "("); for (java.lang.Class ct : pt) { System.out.print(ct.getName() + ","); } System.out.println(")"); } System.out.println(); } **Result:** --Class java.util.regex.Pattern-- java.lang.String toString() int flags() java.util.regex.Pattern compile(java.lang.String,) java.util.regex.Pattern compile(java.lang.String,int,) java.util.regex.Matcher matcher(java.lang.CharSequence,) boolean matches(java.lang.String,java.lang.CharSequence,) [Ljava.lang.String; split(java.lang.CharSequence,int,) [Ljava.lang.String; split(java.lang.CharSequence,) java.lang.String quote(java.lang.String,) java.util.function.Predicate asPredicate() java.lang.String pattern() java.util.stream.Stream splitAsStream(java.lang.CharSequence,) void wait() void wait(long,int,) void wait(long,) boolean equals(java.lang.Object,) int hashCode() java.lang.Class getClass() void notify() void notifyAll() --Class java.util.regex.Matcher-- int end(java.lang.String,) int end() int end(int,) java.lang.String group(java.lang.String,) java.lang.String group(int,) java.lang.String group() java.lang.String toString() boolean matches() java.lang.String quoteReplacement(java.lang.String,) java.lang.String replaceAll(java.lang.String,) java.lang.String replaceFirst(java.lang.String,) boolean find(int,) boolean find() int start() int start(int,) int start(java.lang.String,) java.util.regex.Matcher reset() java.util.regex.Matcher reset(java.lang.CharSequence,) java.util.regex.Matcher appendReplacement(java.lang.StringBuffer,java.lang.String,) java.lang.StringBuffer appendTail(java.lang.StringBuffer,) java.util.regex.Matcher region(int,int,) java.util.regex.Pattern pattern() boolean hitEnd() int groupCount() boolean hasAnchoringBounds() boolean hasTransparentBounds() boolean lookingAt() int regionEnd() int regionStart() boolean requireEnd() java.util.regex.MatchResult toMatchResult() java.util.regex.Matcher useAnchoringBounds(boolean,) java.util.regex.Matcher usePattern(java.util.regex.Pattern,) java.util.regex.Matcher useTransparentBounds(boolean,) void wait() void wait(long,int,) void wait(long,) boolean equals(java.lang.Object,) int hashCode() java.lang.Class getClass() void notify() void notifyAll() java.util.regex.Matcher[pattern=[a-z] region=0,1 lastmatch=]