Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support opening .class files directly within vscode #3

Open
Reggraham opened this issue Nov 2, 2017 · 15 comments
Open

Support opening .class files directly within vscode #3

Reggraham opened this issue Nov 2, 2017 · 15 comments
Assignees

Comments

@Reggraham
Copy link

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
Copy link
Owner

dgileadi commented Nov 2, 2017

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 dgileadi changed the title Java Decompiler Support opening .class files directly within vscode Nov 2, 2017
@dgileadi dgileadi self-assigned this Nov 2, 2017
@railsfactory-prabhu
Copy link

@dgileadi Any update is available for this?

@dgileadi
Copy link
Owner

@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 dgileadi mentioned this issue Oct 25, 2018
@tysun
Copy link

tysun commented May 26, 2019

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
Copy link
Owner

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
Copy link

nitinshambhu commented Aug 6, 2019

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
Copy link
Owner

dgileadi commented Aug 6, 2019

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
Copy link

WORMSS commented Sep 20, 2019

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
Copy link
Owner

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
Copy link

WORMSS commented Sep 20, 2019

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
Copy link

myatmin commented Jun 14, 2020

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

@xeron56
Copy link

xeron56 commented Sep 17, 2021

Any update for this feature addition pls

@Reggraham
Copy link
Author

Reggraham commented Sep 17, 2021 via email

@perennialinnocence
Copy link

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
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants