vscode-java-decompiler icon indicating copy to clipboard operation
vscode-java-decompiler copied to clipboard

Support opening .class files directly within vscode

Open Reggraham opened this issue 8 years ago • 15 comments

It may be a stupid question I am using Visual Studio Code on a MAC and I cannot get the decompiler to work. I load a class file into the editor then go to definition but nothing happens?

Reggraham avatar Nov 02 '17 12:11 Reggraham

Not a stupid question. Opening a .class file directly is something that currently isn't supported. Instead, make sure you have a java project open in vscode and open a .java file that imports the class. Within that java file you can then right-click on that class symbol and choose Go to Definition.

Hopefully in the future we can support opening .class files directly within vscode.

dgileadi avatar Nov 02 '17 17:11 dgileadi

@dgileadi Any update is available for this?

railsfactory-prabhu avatar Mar 05 '18 08:03 railsfactory-prabhu

@railsfactory-prabhu not right now. I have looked into it, though. There are two issues that make it hard.

First, vscode doesn't support directly opening binary files, so for now I'd need to offer something like right-clicking on the .class file and choosing Decompile.

Second, the awesome Redhat Java tools I'm piggy-backing on don't seem to have a method for directly opening a .class file. This means that I need to either make a fairly complicated workaround (search for the type by name and then request its contents) or build my own language server. Neither of those is simple, so I'm deferring for now. PR's welcome!

dgileadi avatar Mar 10 '18 00:03 dgileadi

Any update on this? Why does TextEdit seem to be able to read most of a class file whereas VS can't read any of it?

tysun avatar May 26 '19 19:05 tysun

As mentioned above it's a limitation of vscode and the Redhat Java tools. If you're able to figure out a way to make it work I'd be happy to incorporate your code.

dgileadi avatar May 28 '19 17:05 dgileadi

Within that java file you can then right-click on that class symbol and choose Go to Definition.

This takes me back to the class (.java file) and not .class file. No matter what I do, I can't seem to make it work, unfortunately.

nitinshambhu avatar Aug 06 '19 14:08 nitinshambhu

This takes me back to the class (.java file) and not .class file. No matter what I do, I can't seem to make it work, unfortunately.

I've only seen this kind of behavior when the RedHat Java tools aren't working properly on my project. The decompiler extension depends on the RedHat Java extension to work properly.

dgileadi avatar Aug 06 '19 15:08 dgileadi

I may be even denser here.. but you are talking about .class files.. But I can't even get to that stage..

I can see the .jar file but this is now the point where I am stuck. I don't have a java project I am not writing java. All I want to do is look inside the .jar file.. image

I thought it would look something like this below, but within VSCode. image Am I being unrealistic?

WORMSS avatar Sep 20 '19 14:09 WORMSS

Yes, unfortunately with the current version of the plugin you're being unrealistic. If you had a Java project with your jar as one of the dependencies then it would work—Ctrl+T would allow you to enter the name of a class in the jar to examine and you'd be able to view its decompiled source. Or you could use Red Hat's Java Dependencies view to browse through the jar and click on individual classes within it.

However being able to examine arbitrary .class files or classes within arbitrary .jar files is not something this plugin can do—it relies on Red Hat's java tools for loading class files, and they only work with dependencies in Java projects.

dgileadi avatar Sep 20 '19 14:09 dgileadi

No problem. I have no idea what the jar is doing. I know we call it via command line, but the rest of it is black magic.

const command = `java -jar ${jarFile} generate -i ${swaggerFile} -l typescript-fetch -o ${outDir}`;

I have no idea what classes or files are within it. I will get the Java Decompiler from the above image. Thank you for your help.

WORMSS avatar Sep 20 '19 15:09 WORMSS

Hi @dgileadi, Thank you so much for this extension! Now VSCode support opening binary file with Binary Custom Editor API! 😄

myatmin avatar Jun 14 '20 05:06 myatmin

Any update for this feature addition pls

xeron56 avatar Sep 17 '21 03:09 xeron56

I haven’t seen any updates, I gave up waiting and use IntelliJ as it has a built in decompiler for class files which works well.

Reg Graham

From: MD. SHAHIDUL ISLAM @.> Date: Friday, 17 September 2021 at 04:32 To: dgileadi/vscode-java-decompiler @.> Cc: REGINALD GRAHAM @.>, Author @.> Subject: Re: [dgileadi/vscode-java-decompiler] Support opening .class files directly within vscode (#3)

Any update for this feature addition pls

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/dgileadi/vscode-java-decompiler/issues/3#issuecomment-921428421, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AH6GON5PT7NJNLWXYXZUKKDUCKZE3ANCNFSM4EB6KE6Q. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Reggraham avatar Sep 17 '21 09:09 Reggraham

I've whipped up something to sorta achieve this with .class files https://marketplace.visualstudio.com/items?itemName=perennialinnocence.java-cfr-decompiler Instead of messing with the binary, it simply passes it through CFR, takes the result and passes it to a new .java editor, then kills the original editor.

perennialinnocence avatar Jan 20 '22 06:01 perennialinnocence

I've whipped up something to sorta achieve this with .class files https://marketplace.visualstudio.com/items?itemName=perennialinnocence.java-cfr-decompiler Instead of messing with the binary, it simply passes it through CFR, takes the result and passes it to a new .java editor, then kills the original editor.

Cool!

dgileadi avatar Jan 20 '22 14:01 dgileadi