Recently I have started to have a large appreciation for java’s class loader and jar packages. The combination allowing for many great things that becomes troublesome and cumbersome in other languages. But, I wanted to talk about a few things I believe could be much better.
Embedded jars.
Jar files can have class files in them, even resources in them, but not other jar files. Why not? If I have a project that needs a.jar, b.jar, myproject.jar, it would be simpler and easier to jar up the a & b jars into my jar. I’m not saying this is always the best way to go, but it should be an option.
Monkey Patching.
Monkey Patching is the ability to hack out a solution over someone else nice code. Interpreted languages like ruby or php always get this, since you get the source, not a binary. Now there are lots of bad things about Monkey Patching, but it’s really useful when you need it. Now I understand that if you don’t have source, Monkey Patching is not so practical.
However 100% of the jar files I am currently using are Open Source. As such, there should be a standard way of constructing a Jar file so the source is included. Additionally, there should also be easy ways to recompile the jar.
Like: javac recompile a.jar
Again, the jars I’m using are open source, but the ability to easily modify that source is very complex in java. Also, debugging into those classes usually loses source. We need a simpler way to work with the source the jar was made from.
Distilling Minimum class files.
This would also be nice if you could use the jar file the same as regular source path.
For example, let’s say I have a class my1 which uses a1, and a1 uses b1.
(short hand: my1-> a1 -> b1 ) but my source tree has
my1.java
my2.java
a1.java
a2.java
b1.java
b2.java
if I compile my1.java and let javac know my source path,
it’s will follow the links and only give me
my1.class
a1.class
b1.class
Nice right, the minimum needed to run my class. Now think how nice it would be if you had jar files with source attached,
a1 & a2 are in a.jar
b1 & b2 are in b.jar
but still you could get the same results, a jar file with just the minimum needed to run your app.
Right now, there might be a class that i'd like to use, but i'll rewrite it, because i don't want to include the whole jar that it's packaged in. I can't just remove the class file, because it depends on other class files. So I rewrite rather that bloat.
Why should I ever have to make that choice?
1 comment:
Hi! My name's Enrico. I have a question for you: Did you go to Italy in 1987? I'm trying to get in touch with my old friends Robert and Marcha Falco. Are they your parents? Please contact me on this e-mail address: giomatarazzo@hotmail.it
Post a Comment