Java classloading visualization/analysis tool - jvm

Is there any tool that connects to a jvm and shows you in real time how classes get loaded in that jvm?
I imagine it would make a great jvisualvm plugin..however not finding anything like this makes me wonder if this would be at all feasible?
I only found a few references to some seemingly "obscure" tools, strictly related to weblogic or webspere.
Assuming that such a tool is possible, would it be strictly related to a particular container?
Thanks!

I realize this doesn't work with a JVM that's already running, but how about java -verbose:class?
If you want to debug classloader issues for a specific class, you can connect with a debugger and set a class loading breakpoint for that class (that's how Eclipse calls them, in IntelliJ you just put a breakpoint on the first line of the class).
Update: Since you mentioned you want to see the classloaders, in theory I guess you could write an agent that calls java.lang.instrument.Instrumentation.getAllLoadedClasses() in agentmain and prints a tree of classes and their classloaders. The problem though is that ClassLoader doesn't have an "identity", so you may get a pretty picture but you still don't have any idea which classloader belongs to which Java EE deployment or OSGi bundle. I guess that's why there aren't that many tools that do it...

Related

What is the purpose of sun.jvm.hotspot.HelloWorld?

I just stumbled upon the class sun.jvm.hotspot.HelloWorld. The source of this class is present since Java 6.
The latest version can be found here.
Does someone know the purpose of this class? Is this some kind of developer playground class while developing the JDK?
Thanks in advance!
This file belongs to HotSpot Serviceability Agent.
Serviceability Agent is a kind of internal tool for JVM developers. It is not a part of any public standard, so it does not necessarily need to be covered by TCKs or the separate test suites, though it still has to be consistent with the actual version of HotSpot. I believe HelloWorld was used by JVM developers as a smoke test to make sure Serviceability Agent works in basic cases. So the term "playground class" as you called it fits perfectly.
Frankly speaking, Serviceability Agent source base is not maintained very clean - you may notice other leftover things there. But there is also some interesting stuff, e.g. HSDB or CLHSDB which is a tool for analysing internal structures inside a foreign JVM process.

A java Agent to inspect all JVM running classes?

I am trying do an academic project on BCI and JavaAssist. I would be glad if anyone could help me with these:
Is it possible to build a java agent which can inspect/control all classes running currently in the JVM?
Is it possible to build a java object as a composite of objects(sub objects), so that these sub-objects can evolve dynamically updating their behavior on the fly while the main java object is still running?
The short answer is yes.
As a starting point you could use asm library. This is a usefull presentation http://s3-eu-west-1.amazonaws.com/presentations2012/30_presentation.pdf
This library can be used for instrumentation, inspection and dynamic code generation which can then be loaded using a classloader.

Is there a Maven plugin to generate AS3 classes from Java for BlazeDS?

I'm looking for a maven plugin that would generate ActionScript3 classes from Java classes in order to access them by object remoting.
I've seen FlexMojo but it uses the GraniteDS generator which create some problems when it comes to map Enum objects (which can be fix through a workaround that is describe here : http://dev.c-ware.de/confluence/display/PUBLIC/Flexmojos+generated+AS3+model+with+Enum+support+using+BlazeDS?focusedCommentId=7634946&#comment-7634946 if you've googled your way here this might be useful) when working with BlazeDS.
Everything that I found so far are people who explain how to generate VO classes on flex side using Flash Builder 4, but this solution can not be used in an industrial development environment.
Take a look also on http://flex-annotations.aixcept.net/examples/actionscript.html
I also found this one, and while it is not a maven plug-in it could possibly be turned into one:
https://sourceforge.net/projects/cleartoolkit/
It was created by the guys who authored the book "Enterprise Development with Flex". Look for the utility DTO2Fx.

Rich Internet application solutions

I am evaluating Rich Internet application solutions to use in next project. I have heard of following solutions -
Adobe Flex
extJS
Jboss Richfaces
IceFaces
Oracle ADF
JavaFX
Silverlight
GWT
I want to know if there are more solutions available.
I would appreciate if you can provide any valuable feedback on the above solutions.
IT Mill Toolkit is a "server-driven" framework built on top of GWT.
Comment: coming from a heavy PHP and Java-hostile background, I found Toolkit to be very pleasing to use pretty quickly. Being able to write nothing but (the strongly typed, nicely OO-oriented) Java is nice, considering the fact that what you change in the code is pretty instantially reflected on what you see in the browser.
It's a bit tricky to set up, but IT Mill has an Eclipse plugin that supposedly helps with that. The only thing is that the plugin itself is a tad unintuitive to use :)
0.02€
Reply to comment: The biggest difference between GWT and IMT is that GWT operates entirely inside the browser (a hostile/exploitable environment with e.g. FireBug), while IMT uses GWT only to render the server-side state. So, while you can edit any values you want in the browser with both GWT and IMT, GWT will happily accept the user-edited variable values, IMT keeps track on the values server-side, and doesn't allow any discrepancies between the client and server.
Another big difference is that GWT widgets need to be compiled every time you do any changes to them with the relatively time consuming GWT cross-compiler (compiles Java to JavaScript). IMT, on the other hand, needs only to be redeployed to the servlet container, and the changes are there, because the GWT widgets inside IMT don't need to be recompiled. With Tomcat, it's virtually instantaneous (i.e. as soon as Tomcat notices that Eclipse has recompiled the classes on the fly).
#the_drow: Not being familiar with Dijit, here's an answer: Dojo is javascript only, meaning it's client side only. Vaadin (née IT Mill Toolkit) lives partly in the server side too (calls itself "server driven"), so you can't hack the client side just by changing JavaScript variable values. There's a chart that compares Vaadin with other comparable products. Dojo isn't included, but JQuery is, which is vaguely similar to Dojo
i had an experience with Spring Webflow + Rich Faces with mixed results - time to get the results on screen is really short, but it's pain to fine tune the presentation part.
ie if you are building some tech oriented/backend
/standard GUIs - it's ok, if you are going to build a frontend used by millions web2.0-ers you end up messing with presentation part css/javascript big time.
After evaluating and reading various RIA solutions, I have finally selected GWT and GWT-Ext. I see these benefits for me and my team -
We are used to Eclipse so this is an advantage.
Ability to use Java Debugger in Eclipse is extremely helpful.
GWT Hosted mode in eclipse, so no compile and deploy required on every change.
Big developer community
Lots of ready to use components
Prior Java knowledge helpful
Similar to swing and the team have worked on Swing in earlier project.
Look and feel is also good
Maven support is also available.
Can write Junit test cases.
No other language knowledge required apart from Java.
Easy RPC configuration based on annotations.

Is this a reasonable "Application entry point"?

I have recently come across a situation where code is dynamically loading some libraries, wiring them up, then calling what is termed the "application entry point" (one of the libraries must implement IApplication.Run()).
Is this a valid "Appliation entry point"?
I would always have considered the application entry point to be before the loading of the libraries and found the IApplication.Run() being called after a considerable amount of work slightly misleading.
The terms application and system are terms that are so widely and diversely used that you need to agree what they mean upfront with your conversation partner. E.g. sometimes an application is something with a UI, and a system is 'UI-less'. In general it's just a case of you say potato, I say potato.
As for the example you use: that's just what a runtime (e.g. .NET or java) does: loading a set of libraries and calling the application entry point, i.e. the "main" method.
So in your case, the code loading the libraries is doing just the same, and probably calling a method on an interface, you could then consider the loading code to be the runtime for that application. It's just a matter of perspective.
The term "application" can mean whatever you want it to mean. "Application" merely means a collection of resources (libraries, code, images, etc) that work together to help you solve a problem.
So to answer your question, yes, it's a valid use of the term 'application'.
Application on its own means actually nothing. It is often used by people to talk about computer programs that provide some value to the user. A more correct term is application software and this has the following definition:
Application software is a subclass of
computer software that employs the
capabilities of a computer directly
and thoroughly to a task that the user
wishes to perform. This should be
contrasted with system software which
is involved in integrating a
computer's various capabilities, but
typically does not directly apply them
in the performance of tasks that
benefit the user. In this context the
term application refers to both the
application software and its
implementation.
And since application really means application software, and software is any piece of code that performs any kind of task on a computer, I'd say also a library can be an application.
Most terms are of artificial nature anyway. Is a plugin no application? Is the flash plugin of your browser no application? People say no, it's just a plugin. Why? Because it can't run on it's own, it needs to be loaded into a real process. But there is no definition saying only things that "can run on their own" are applications. Same holds true for a library. The core application could just be an empty container and all logic and functionality, even the interaction with the user, could be performed by plugins or libraries, in which case that would be more an application than the empty container that just provides some context for the application to run. Compare this to Java. A Java application can't run on it's own, it must run within a Java Virtual Machine (JVM), does that mean the JVM is the application and the Java Code is just... well what? Isn't the Java code the real application and the JVM just an empty runtime environment that provides nothing to the end user without the loaded Java code?
I think in this context "application entry point" means "the point at which the application (your code) enters the library".
I think probably what you're referring to is the main() function in C/C++ code or WinMain in a Windows app. That is, it's the point where execution is normally started in an app. Your question is pretty broad and vague--for example, which OS are you running this on--but this may be what you're looking for. This might also address the question.
Bear in mind when you're asking questions, details are your friend. People can give you a much better, more informed answer when you provide them with details.
EDIT:
In a broader context consider what has to happen from the standpoint of the OS. When the user specifies that they want to run an app, the OS has to load the app from the hard drive and then when the app is loaded into memory, it has to pass control to some point in the memory blocked occupied by the newly loaded app to continue execution. That would be the "Application Entry Point". When an app is constructed with dynamically linked code the OS has to load all that dynamically linked code in order to get the correct app image into memory. Loading up those shared bits of code does not change the fact that the OS must have a point to which to pass control when the app is loaded into memory.