A java Agent to inspect all JVM running classes? - jvm

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.

Related

Can javascript generated from Kotlin sources be used back in JVM?

Is it possible to use js generated from Kotlin sources in JVM to manipulate java objects and its own js objects?
Kinda create dynamic environment for development in distributed environment.
So new versions of classes can be dynamically loaded/modified on running remote servers while development. And then after it's done release versions to be compiled statically for max performance.
How hard would it be to implement?
The current implementation of Kotlin does not have any support for invoking Java methods from JS-generated code. This could in theory be accomplished using Nashorn, but we (the Kotlin team) do not currently have any plans to work on that. If you're interested, you're welcome to contribute, but this would be a fairly long and difficult project.

Call .net methods into java without using C/C

Can anybody explain how can i call .net methods(from .dll) in my java code but i dont want to write/use C/C++ Code please expalin it Step by Step
You haven't given us any information to work off (How large are the two projects? Are you forced to use a specific CLR/JRE? Can they be two separate processes or do you just need to access a bunch of methods? Stuff like that), but I can point you in a general direction...
IKVM.NET is an implementation of Java that runs on the CLR. If you run your Java program in there, you can interop with any other .NET language easily.
If you can't use this for some reason, then you're probably going to have to embed Mono in your application and write some JNI bindings to start an instance of the CLR, then load and invoke your code.
If you've got a small amount of methods, consider just porting the code to Java instead of creating this huge system in order to get a small amount of functionality.
I can't explain it step by step because you haven't provided very much information as to what restrictions you have or how it needs to be done. Also, this isn't something trivial. You're trying to get two language runtimes to interact with each other without using native code, when native code is the only thing either runtime can interoperate with.

Java classloading visualization/analysis tool

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...

Compiling Scheme to Java and/or Objective-C

We have Bigloo.NET does anyone know of such a project that offers the same but for the Java and/or Objective-C language?
I am developing a component of a project that will also have a Windows and Apple GUI built around it. Would be nice if I could develop this component in a single language and have it compiled into the native language for the current GUI. Any ideas?
Do you know that Bigloo initially targeted the JVM, and only later the CLR? I'm assuming you do, and that it's insufficient for you. If you weren't aware:
Java code and Bigloo code can be
merged together. Bigloo functions can
call Java functions and vice-versa,
Bigloo code can use and instantiate
Java classes. Bigloo functions and
variables can hold Java values (Java
classes values). Bigloo data
structures can point to Java data
structures and vice-versa.
If that doesn't do it for you, but you still want a Lisp, Clojure is a Lisp, though neither Scheme nor Common Lisp. It shares with Scheme a single namespace for functions and variables, however, and I've found it pretty comfortable in my short acquaintance with it. Clojure is also Java --- anything you do from Clojure can be used from plain Java, and vice versa.
Maybe you could give more detail on why Bigloo doesn't work for you, and that could help us give better answers.
Schemes for the JVM: SISC and JScheme. Both are interpreters with good Java interoperability.

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.