dgileadi / vscode-java-decompiler

Decompiler extension for Java in Visual Studio Code
Eclipse Public License 2.0
51 stars 20 forks source link

Support opening .class files directly within vscode #3

Open Reggraham opened 6 years ago

Reggraham commented 6 years ago

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?

dgileadi commented 6 years ago

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.

railsfactory-prabhu commented 6 years ago

@dgileadi Any update is available for this?

dgileadi commented 6 years ago

@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!

tysun commented 5 years ago

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?

dgileadi commented 5 years ago

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.

nitinshambhu commented 4 years ago

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.

dgileadi commented 4 years ago

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.

WORMSS commented 4 years ago

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?

dgileadi commented 4 years ago

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.

WORMSS commented 4 years ago

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.

myatmin commented 4 years ago

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

xeron56 commented 2 years ago

Any update for this feature addition pls

Reggraham commented 2 years ago

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.

perennialinnocence commented 2 years ago

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.

dgileadi commented 2 years ago

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!