I am developing an application in Eclipse, with frames. In some of the panels I allow the user to paste data from his clipboard. It is usually quiet. The problem is when what is on the clipboard has been copied from intelliJ (due to IntelliJ causing everything that is copied to become a serialized object) and results in an exception (ClassNotFoundException) and I can't catch it.
Does anyone know how to avoid this, in code?
Exception:
Exception "java.lang.ClassNotFoundException: com/intellij/codeInsight/editorActions/FoldingData"
while constructing DataFlavor for:
application/x-java-jvm-local-objectref;
class=com.intellij.codeInsight.editorActions.FoldingData
The obvious answer would be to catch the exception and ignore it.
If you can't do that, some possibilities are:
Develop a patch to Eclipse that allows a plugin to suppress these exceptions ... somehow1. Then submit an Eclipse bug report, providing your patch as a solution.
Get the user to add the Intellij "idea.jar" file to the Eclipse classpath so that Eclipse can deserialize these objects. You may then need to make further modifications to your plugin to allow it to make sense of the IDEA objects that you user is trying to copy and paste into Eclipse.
Document that your plugin does not support copy / paste from Intellij IDEA.
I couldn't see any way to stop Intellij from putting serialized objects into the clipboard.
UPDATE - I did some more research on this. The string
"while constructing DataFlavor for:"
appears in the source code for java.awt.datatransfer.SystemFlavorMap. That suggests that the problem is actually the same one as has been reported as Java bugs JDK-6606476 and 8246248. (In the latter case, the problem is triggered by certain kinds of JPEG files.)
Examining the source code suggests that it ought to be possible to work around this problem; e.g. by creating and registering a custom DataFlavor and implementing a DataContentHandler / DataContentHandlerFactory to take care of the conversion2. However, I can't give you specifics.
1 - It turns out that the problem is probably NOT in the Eclipse code base after all.
2 - Unless you fancy decoding Java serialization format by hand, I suggest you "deserialize" this stuff as content-free objects ... and get your application to quietly ignore DnD events for this kind of data.
Related
Do you know any way to find (un)used code from the perspective of a specific main method (or what IntelliJ calls an entry point)?
The background is that we have a big java project in which we have custom code for several clients. Sometimes we give clients the current state of the project in source form but would obviously want to remove the parts which only concern other clients. We have a Main file for each client so it should be possible to follow imports from there to find exactly the files relevant to each client.
I was hoping to be able to run intellij's code inspection on a single entry point but was unable to find anything. I'm open to any solution though.
You could remove all other entry points and run intellij's code inspection again to detect unused code. Now that you have only one entry point it should be able to tell you what code is unused. With that knowledge you can revert you changes and remove this code.
Hope that helps.
So, at my job, I've got a ticket to fix a bug that I'm not really sure is fixable. So, here's the deal:
Our application is a java Swing app that configures the under-the-hood engine that runs. All of our machines at the office are Macs, but to ensure cross-platform functionality we frequently do things in Windows VMs.
So, the guy who reported this, is working in his Windows VM using VirtualBox. He copies some text from our application in the Windows VM to our application in Mac. Our application saves its state in XML configuration files. When he then saves the changes, the text in the XML config file has a "?" character where the FEFF control character was.
Now, I've been going over our code. The paste operation drops the code into a JTable with a custom CellEditor, but the cell editor has nothing special regarding copy/paste operations. Literally no code whatsoever on that issue.
When the application then goes to write everything to the XML configuration file when it saves, it uses the org.w3c.dom.* libraries (the standard Java XML libraries) to do it. Again, can't see anything special here.
My gut says that this might not be solvable, that it might just be an issue from copying between VMs, something is getting weirdly corrupted. Anyone else ever encounter something similar or have an idea on this?
I really don't have any code samples to paste here, but anything anyone could ask for I'll try to provide.
Is it possible to set the java decompiler to return everything it finds during the process? I have a game I have been working on for a little over a year, I am still pretty new to java and have been beating my head against the keyboard and api documentation to produce this game. I come home from a business trip and find that my house has been broken into and my workstation is gone. I still have my keystore because I keep it on a flashdrive for safety. I also keep my project files on a flashdrive, which I did not remove from my workstation before leaving on my trip. I have tried to use every .apk decompiler I can find to recover my source code. They all return some code but of course because of proguard almost all of it is unusable. I have a copy of my signed .apk on my phone for testing purposes and it is debuggable, is there anyway to recover all of my project files from this? Like setting the java decompiler to very verbose, or a different setting that will produce a 1:1 copy of each file reguardless of if the decompiler thinks it is relavent?
Edit: I have used dj java decompiler, androchef decompiler and the decompiler # www.decompileandroid.com which is just a script that is run on their server to use the standard tools included in eclipse adt package for developing android applications.
I used to deobfuscate Java applications for a hobby and have worked on several decompilers, so if you send it to me, I might be able to help.
That being said, there are some things that are simply impossible to fix. You're never going to get back anything that isn't present in the compiled apk because it's impossible to recover information that isn't there. Among other things, this includes comments, original source code formatting, and compile time annotations. The obfuscation step will also strip out class names, variable names, unused methods, etc.
One other thing to try is to see if there's any possible way that a non obfuscated version of apk survived. Did you ever upload your files anywhere else?
Here's what I'm trying to do: I have an eclipse plugin that contains certain data (actually Strings representing the file structure of a project). These Strings are acesssible over usual getters and are stored in Lists. I now want to put these Strings into BIRT to get a pdf or html. From what I found out so far, I will need to integrate BIRT in the plugin somehow (I do not want to have to select a data source and data set and so on like you'd have to using BIRD's UI - this should happen automatically in my code). Further, I wouldn't like to use the BIRT runtime, but only the normal jars you get from the common installation way over eclispe->help->istall new software. Is that even possible without the runtime and without digging really deep in the BIRT source files? I am actually looking for something like:
Datasource source = new DataSource();
/* put somehow the strings into the data source */
DataSet set = new DataSet();
/* connect set to source, create layout and so on */
This is the mthod I'm currently working in:
#Override
public Object execute(ExecutionEvent event) throws ExecutionException {
/* the strings are accessible over "fs" */
FileStructure fs = extractFileStructure(event);
/* TODO: Implement the layout */
}
I hope my question's clear enough :).
Alright, I managed to answer this question myself, so I'm going to answer it in case someone has the same problem.
Actually my question was slightly silly because I didn't really know what I was talking about. I don't think it's very wise to try to implement this without using the BIRT runtime. What I was talking about was the installation of the BIRT runtime environment (where you had to set a HOME variable and so on) which was only necessary before version 3.7 of BIRT. Now you can just skip this step which is exactly what I wanted. Actually it's not such a big deal. All the information I needed could be found in this eclipse tutorial. But I recommend you not to copy the code straight away because the tutorial seems to be a little older, so some of the methods used there are deprecated in the current BIRT version (they actually might have been disappeared if you read this post later).
I hope that this was/is helpful for some of you. :)
I use Eclipse to write Java code and use DropBox to sync my code with others' across our multiple computers. Most of the time, everything works as expected: if anyone makes a change on either end, the change is saved and when the other person refreshes the Eclipse workspace, the changes come through and can be viewed and run successfully.
Sometimes, one of several errors arises. Sometimes Eclipse says it cannot find a main class and sometimes it says it could not find the class itself. Sometimes it will not report an error but for some reason will not actually update the .class file and therefore run an old version even though the compiler displays the new source code and that saves. I've then noticed that if I manually copy the code into a new .java file elsewhere in the file system and then compile it, it works fine, but for some reason it refuses to regenerate the .class file and I have to delete it manually and replace it with the one generated in the other project--then it works. But for solving the other problems everything needs to be manually copied, deleted, and re-pasted....
[The actual errors include NoClassDefFoundError, UnsupportedClassVersionError, and some other error related to not having a main class.]
I realize that the description here is somewhat vague, but unfortunately I'm not entirely sure what's going on. I hope I'm just missing some basic fact that would help solve all these problems.
Thanks!
I'm sure you will see issues using Dropbox for sharing your source.
Eclipse does not know what Dropbox is doing whilst it's uploading and downloading updates and their activities will certainly not be synchronised. At arbitrary points in time when Eclipse tries to do builds etc. it will find unexpected activity going on, maybe even partially downloaded source files which might explain the specific errors you are seeing.
You're trying to do something more complex than sharing photos or documents. The advice I would give is to use a source control system like git or subversion for source code sharing and control. You can then make use of plugins for Eclipse that are designed to integrate these systems in an easy to use way. There's a learning curve there, but the skills will serve you well.
You can use online versions of these solutions like github and unfuddle if you want to consume sharing, backup and version control of source as a service like you do with Dropbox. They're free, too.
Subversion, Git and all version control software solve all of these problems for you.
Dropbox is not really an adapted system for sharing code. What you should do is set up a SVN, and commit only the source files. This way, you won't have these kind of errors.
Dropbox does have versioning (you can restore old versions of a file), and doesn't seem to be a horrible solution for the problem. I keep my Eclipse repository on Dropbox so it is available on any computer; but since I only use it myself, I haven't encountered your problems.
There is one case I can absolutely see you running into problems--it's if your class files are stored in the dropbox as well. This would just screw everything up. Make sure you specify a location on your local hard-drive for all build artifacts (classes, jars, ...) and that the only thing on your dropbox is the .java sources.
In fact, I suggest you don't keep your eclipse project in your dropbox, just create your eclipse project and point it to the java files in your dropbox.
If this doesn't work for you, go with what other people here said and set up a SVN repository somewhere, it's easier than you would think.
Oh, another possible problem--dates! You may want to make sure the date on your java files isn't jumping forwards and backwards (as might happen if one of your developers were in another time zone). In this case, Eclipse may prefer not to re-compile your file.
Also, instead of the copy/etc procedure you are currently going through, try forcing a project clean.
Response to request for more info:
When you start Eclipse, select/create a workspace that is NOT on your dropbox. The best place is probably off your home directory. If you have already specified a default workspace, there should be a switch workspace item in the file menu.
Create your project. select "Create project from existing source" and specify the source files in your dropbox. I think you want "create separate folders for source and class files" to keep your class files out of your dropbox. If you see anything saying "Copy files into your workspace, say "no".
This should give you a valid, working project. I hope you don't see those problems any more.
One more thing may help--and this may work on your existing project--without the above procedure...
Whenever you refresh your files (f5) to load in changes from the dropbox, select the Project/clean menu and select the project. This should delete all the class files and rebuild them.
If your classfiles are shared on the dropbox, this could still have strange consequences on other people with eclipse open, so I really do suggest rebuilding your workspace as I said above.
How to avoid no main class
Provide one. That issue has nothing to do with DropBox