{"id":2363,"date":"2012-03-01T23:37:16","date_gmt":"2012-03-01T22:37:16","guid":{"rendered":"http:\/\/www.gamlor.info\/wordpress\/?p=2363"},"modified":"2021-03-11T09:14:42","modified_gmt":"2021-03-11T08:14:42","slug":"decompiling-scala","status":"publish","type":"post","link":"https:\/\/www.gamlor.info\/wordpress\/2012\/03\/decompiling-scala\/","title":{"rendered":"&rsquo;Decompiling&rsquo; Scala"},"content":{"rendered":"<p>Somehow I often end up in a situation where I need to take a look at what the Scala compiler generates, mainly at the class-signature of the generated stuff. So here is a list if the tools I frequently use for doing this.<br \/>\n<div id=\"attachment_2377\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/the-left-overs.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2377\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/the-left-overs-300x164.png\" alt=\"And what did your Scala compiler ate this week?\" title=\"the-left-overs\" width=\"300\" height=\"164\" class=\"size-medium wp-image-2377\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/the-left-overs-300x164.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/the-left-overs.png 770w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-2377\" class=\"wp-caption-text\">And what did your Scala compiler ate this week?<\/p><\/div><\/p>\n<h2>IntelliJ IDEA<\/h2>\n<p>Well, I\u2019m usually hacking Scala in Intellij, so why not using it as a \u2018decompiler\u2019. When you drop a class file into IntelliJ it shows the signature of the class. Well, with the Scala plugin installed it shows a Scala outline, which is nice. However when you want to see the raw signature it is kind of pointless. Without the Scala plugin you will see the regular Java outline.<br \/>\n<div id=\"attachment_2366\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/intellij-with-scala-plugin.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2366\" class=\"size-medium wp-image-2366\" title=\"intellij-with-scala-plugin\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/intellij-with-scala-plugin-300x133.png\" alt=\"With Scala Plugin\" width=\"300\" height=\"133\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/intellij-with-scala-plugin-300x133.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/intellij-with-scala-plugin.png 556w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-2366\" class=\"wp-caption-text\">With Scala Plugin<\/p><\/div><div id=\"attachment_2365\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/intellij-without-plugin.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2365\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/intellij-without-plugin-300x281.png\" alt=\"Without Scala Plugin\" title=\"intellij-without-plugin\" width=\"300\" height=\"281\" class=\"size-medium wp-image-2365\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/intellij-without-plugin-300x281.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/intellij-without-plugin.png 719w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-2365\" class=\"wp-caption-text\">Without Scala Plugin<\/p><\/div><\/p>\n<h2>Javap<\/h2>\n<p>The JDK brings its own decompiler and it does its job well. The scalap command will decompile class files to a simple text output. Depending on the arguments it shows the outline or all the byte code details. So, this little tool is your friend.<\/p>\n<p>Just run the javap command to see what options are available. Javap will print its result to the standard out, so you just can pipe to the proper place.<\/p>\n<p><div id=\"attachment_2369\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/scalap-signature.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2369\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/scalap-signature-300x167.png\" alt=\"Javap-Signature\" title=\"scalap-signature\" width=\"300\" height=\"167\" class=\"size-medium wp-image-2369\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/scalap-signature-300x167.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/scalap-signature.png 741w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-2369\" class=\"wp-caption-text\">Javap-Signature<\/p><\/div><div id=\"attachment_2368\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/scalap-bytecode.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2368\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/scalap-bytecode-300x179.png\" alt=\"Javap Bytecode\" title=\"scalap-bytecode\" width=\"300\" height=\"179\" class=\"size-medium wp-image-2368\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/scalap-bytecode-300x179.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/scalap-bytecode.png 970w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-2368\" class=\"wp-caption-text\">Javap Bytecode<\/p><\/div><\/p>\n<h2>Classfile Analyser<\/h2>\n<p>This <a href=\"http:\/\/classfileanalyzer.javaseiten.de\/\">little tool basically<\/a> does more or less the same as Javap. However it uses a different output format, namely the <a href=\"http:\/\/jasmin.sourceforge.net\/\">Jasmin 2 \u2018bytecode\u2019<\/a> assembler. Certain things are easier to read here than in the Javap output. For example annotations:<br \/>\n<div id=\"attachment_2374\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/classfile-analyzer-vs-scalap.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2374\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/classfile-analyzer-vs-scalap-300x62.png\" alt=\"ClassAnalyer vs Javap\" title=\"classfile-analyzer-vs-scalap\" width=\"300\" height=\"62\" class=\"size-medium wp-image-2374\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/classfile-analyzer-vs-scalap-300x62.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/classfile-analyzer-vs-scalap-1024x213.png 1024w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2012\/03\/classfile-analyzer-vs-scalap.png 1194w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-2374\" class=\"wp-caption-text\">ClassAnalyer vs Javap<\/p><\/div><\/p>\n<h2>Java Decompilers<\/h2>\n<p>I sometimes used freely available Scala decompilers to take a look at Scala class files. However those tend to fuck up when generating Java code for certain Scala constructs. That often adds confusion instead of clearing things up. I would recommend sticking to javap etc. which do not attempt to create Java code.<\/p>\n<p>Well maybe there is a really good decompiler out there which works flawless. In case you have a different experience, let me know.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Somehow I often end up in a situation where I need to take a look at what the Scala compiler generates, mainly at the class-signature of the generated stuff. So&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[15],"tags":[261,295,226],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/2363"}],"collection":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/comments?post=2363"}],"version-history":[{"count":13,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/2363\/revisions"}],"predecessor-version":[{"id":3745,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/2363\/revisions\/3745"}],"wp:attachment":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/media?parent=2363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/categories?post=2363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/tags?post=2363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}