Original Question
Are there any libraries which exist that allow you to parse a remote
HTML version of javadocs?
Aside from custom Json/Gson implementations, do any libraries exist for something like
Map<Class, Entry<Field[],Method[]>> data = Library.get("website.com/docs");
Original Goal
Load all available API calls into something I'm working on and use
reflection to make those API calls.
Original Problem
I've done countless searches and can not seem to find anything. Of
course I can do it myself, but I'd rather save myself the time if
something already exists.
Solution: I've created something to download the javadocs, parse them, and store them into the memory value defined above in the original question section.
If anyone approaches this question aiming to find the same thing, feel free to comment or message me.
Related
I am developing a Minecraft plugin which uses a class that I made called customPlayer. When I save the plugin data from a running instance, I put all of these objects into a HashMap<String,customPlayer> and save them with ObjectOutputStream. Loading these classes back into the same version of the plugin works great, but my problem arises when I modify the class and try to read the object using that modified class (usually associated with a new version of my plugin).
I thought about it for a bit, and thought I came up with a clever solution. My idea was to just include the old class files as an External Library inside the new version of the plugin, cross my fingers and hope it worked. It didn't.
Is there a better way to do this? I'm new to serialization and this kind of stuff, so any suggestions would be greatly appreciated. Below I will include a few Screenshots of the customPlayer class and the crash log of the server. Ideally any solution that is presented should be able to be used easily with future modifications to the class (Updates to the Jar downloaded Via a Github repo).
Instance Variables and Constructor of customPlayer.java
Is there a better way to do this?
There certainly is. Stop using Serialization and ObjectOutputStream. These classes are a disaster (even OpenJDK core team effectively agrees with this assessment). The output they generate is not particularly efficient (it's more bytes than is needed), it is not human readable, nor (easily) read by anything except java code, and it results in such hairy situations as you ran into.
Instead use e.g. Jackson to turn your objects into JSON, or use google's protobuf to turn it into efficient binary blobs.
You can read this JSON or these binary blobs in any language you want and you'll have your pick of the litter as far as libraries go. You will need to write some explicit code to 'save' an object (turn it into JSON / protobuf), and to 'read' one, but now you are free to change your code.
If you insist on continuing with serialization, you need to add a field named serialVersionUID, and set up readObject and writeObject. it's convoluted rocket science that's hard to get right. The details are in the javadoc of java.io.Serializable.
Do yourself a favour though. Don't do it.
I am going to need the ability to programmatically modify Java source code, specifically apply refactorings. For example moving a method from one class to another, changing an access modifier from public to private, etc.
Now in C# I'd probably go the abstract syntax tree / Roslyn approach, but I have no idea where to even begin in Java.
Given a java source code file, how does one parse it so that modifications can be made and then saved to it?
First: Things like that (called refactoring) are already handled by a good Java IDE (Eclipse, IntelliJ IDEA, NetBeans and you name it). I really think that stuff like that should be handled by an IDE.
Second: If you really want to edit the files programmatically keep in mind that you're the one who is in charge of format and syntax. You have to read the files, edit them (cut out, paste in or add some code at proper line) and save them. The link provided from VedX is a good start for basic IO. But there is so much more to keep track of.
I did something similar with OpenEdge ABL and it is no easy task (you'll find things that went wrong you never thought of and if you didn't backed up your code it's f**ked up). I've got it done but in the end it wasn't a good trade-off between time spend to get it done and actual usefullness (I just needed it about 4 times for approx. 1500 files).
Finally (after I lost many hours inventing the wheel of refactoring) I wrote some class generators which wrote a whole new file evertime I needed to change something - lastly I only changed the class generators (maybe this is something you didn't thought of and it fits too). Now it's automatized and generic and could run in parallel (something what OpenEdge isn't designed for - okay it's a cheap hack by me).
Third: Maybe there is a package you can use in your Java project. I would try to Google it. My first attempt resulted in this: http://www.methodsandtools.com/archive/archive.php?id=4 for first understanding what it's all about and what to consider.
I am trying to develop a simple statistics tool to analyse various behaviours of collaborators within an Evernote Notebook using the Evernote Java API.
I need the informations which user edited which note and when.
Even though the documentation is quite good, I am still unable to find the required functionality inside the api.
(TLDR:)
Is there a way to access a list of edits of a evernote note using the API?
I am not bound to using the Java SDK so if there is a way, which is limited to using another language, it would be no problem to switch.
Andreas - Did you look into these methods in the API?
NoteStore.GetNote and NoteStore.getNoteApplicationData
It sounds like this would be a decent place to start at the very least. I cannot say for certain if this will return everything you are looking for though.
I hope this helps!
I'm not exactly sure what you are looking for but NoteStore#listNoteVersions might be the one you want. You can get a list of NoteVersionId and then use another API called NoteStore#getNoteVersion to get metadata to see which note is updated when.
Note that the API is probably only for premium accounts.
Basically, I am looking for a simple way to list and access a set of strings in stream form in an abstract manner. The only issue is that Java's file-accessing API can only be used for listing and reading files, and any sort of non-filesystem storage of the data uses a different API. My question is whether there is some common API I could use (whether included in Java or as an external API) so that I could access both in an abstract manner, but also somewhat efficiently.
Essentially I want a set of lazily streamed text files. Something like Set might be reasonable, except on a filesystem, you would have to open the text streams even if you don't end up wanting to access that file.
Some sort of api like
String[] TextStorage.list()
InputStream TextStorage.open(String elementname);
which could abstractly be used to access either filesystems or databases, or some other storage mechanism I invent in the future (maybe fetching something across the internet).
Is there a library which already does this? Can I do this with the already existing Java API? Do I need to write this myself? I'd be surprised if no-one has encountered this problem before, but my google-fu and stackoverflow searches don't seem to find anything.
you might use HSQL
http://hsqldb.org/
I'm working on a project where we're doing a lot of remote object transfer between a Java service and clients written in other various languages. Given our current constraints I've decided to see what it would take to generate code based on an existing Java class. Basically I need to take a .class file (or a collection of them) parse the bytecode to determine all of the data members and perhaps getters/setters and then write something that can output code in a different language to create a class with the same structure.
I'm not looking for standard decompilers such as JAD. I need to be able to take a .class file and create an object model of its data members and methods. Is this possible at all?
I've used BCEL and find it really quite awkward. ASM is much better. It very extensively uses visitors (which can be a little confusing) and does not create an object model. Not creating an object model turns out to be a bonus, as any model you do want to create is unlikely to look like a literal interpretation of all the data.
I have used BCEL in the past and it was pretty easy to use. It was a few years ago so there may be something better now.
Apache Jakarta BCEL
From your description, it sounds like simple reflection would suffice. You can discover all of the static structure of the class, as well as accessing the fields of a particular instance.
I would only move on to BCEL if you are trying to translate method instructions. (And if that's what you're trying to automate, good luck!)
I'm shocked that no one has mentioned ASM yet. It's the best bytecode library your money can buy. Well, ok it's free.
JAD is a java decompiler that doesn't allow programmatic access. It isn't readily available anymore, and probably won't work for newer projects with Java7 bytecodes.
I think javassist might help you too.
http://www.jboss.org/javassist/
I have never had the need of using it, but if you give it a try, would you let us know your comments about it?
Although I think it is more for bytecode manipulation than .class inspection.