Decompiled java AST representation

91 views
Skip to first unread message

Vladimir Maximovich

unread,
Apr 21, 2020, 7:57:20 PM4/21/20
to JEB Decompiler
Hello,
So I've been playing a little with JEB plugins and scripts. I saw there is a script for decompiling all the bytecode and creating corresponding JAVA files.
I was wondering, by the use of Java plugins or Python scripts - is there any way to take this decompiled Java files and work with their AST elements?
I mean, when the input is a java file, I want to work with the AST elements themselves, either to manipulate them or simply just to "break the Java" to it's smallest components. 
I want to get a full tree of the class where I know all the methods, variables, names, types, ... - and be able to save the representation or change names with code (both plugins and scripts are acceptable here).

Thank you)))

Nicolas Falliere

unread,
Apr 21, 2020, 8:26:53 PM4/21/20
to Vladimir Maximovich, JEB Decompiler
Yes of course, e.g. for a class:

// if you already have a decompiled code unit, IJavaSourceUnit, such as produced when decompiling using decompile()
// src is an IJavaSourceUnit
IJavaClass c = src.getClassElement()

// if you're going though a decompiler object directly:
// dexdec is a IDexDecompilerUnit object
//  IJavaMethod is a top-level AST element
IJavaMethod m = dexdec.getMethod("Lcom/foo;f()V")
//  IJavaClass is another top-level AST element  
IJavaClass c = dexdec.getClass() "Lcom/foo;")

Have a look at this dummy script, it's taking an AST element and printing the tree recursively using getSubElements()

Hope this helps - let me know if you have more questions. And you should join us on Slack (see link in my sig below), for a more interactive conversation!

--
Nicolas Falliere (ni...@pnfsoftware.com)
JEB Decompiler, Founder and Architect


--
You received this message because you are subscribed to the Google Groups "JEB Decompiler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jeb-decompile...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jeb-decompiler/392e8597-43e0-441b-8f93-131a34007a30%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages