Determine object hierarchy of java class generated by XJC - java

I have a XSD file ( which contains complex structure ). I generated java class using XJC command.
Now I want to know which is parent class and which is child class programmatically.
Any idea or help will be highly appreciated
Cheers

I suggest using the Java Reflection API, more specifically the Class.getSuperClass() method.

Related

how to directly work with `xsl` from Java?

Using Java to write xml strikes me as perhaps not the best match. Is this just because it's new and unfamiliar, perhaps?
Rather than generating JAXB source code from xml might it not be more flexible to work with xml files directly? What I mean is, cannot the middle-man be cut out?
If JAXB can generate source code for the class files to manipulate xml might there a tool which uses JAXB without creating concrete boiler-plate?
If there's simply a mis-match making this impossible please elaborate. Or, if it's simply out of reach, what are the obstacles?

Where are annotations stored in class file

I am trying to instrument a class file, but I was just wondering where annotations are stored in the class file format. I tried putting them in the interface table however, when I did that it only recognized them as an interface not as an annotation.
They are stored in the RuntimeVisibleAnnotations and RuntimeInvisibleAnnotations attributes for classes and methods class members, and the RuntimeVisibleParameterAnnotations and RuntimeInvisibleParameterAnnotations attributes for method parameters. You can find more detailed information about the classfile format in the Java VM Specification.
When trying to understand Java bytecode, a good starting point is writing in plain Java the class you would like to create using bytecode. Compile it, then use tools to retrieve generated bytecode.
Here's some tools I can think of :
ASM's Textifier (this class has a main method to make it easy to run)
Intellij IDEA Show bytecode view
Bytecode outline plugin for Eclipse

How to generate XMI file for the java source code?

I'm writing a program in java language which takes the java source code as an input and the output is xmi file which contains the class diagram of the source code.
I have researched for xmi structure but I was not able to find an adequate resource which explain the structure and order of tags.
First question is how can I found out what is the order of the tags and definition of each tag? for instance, what is the meaning of "isActive = false" etc?
Secondly, is there any suggestion of libraries or anything in java language which can help me to finish this project?
I think the tag order doesn't matter in XMI. In general, XMI just defines how to map MOF to XML. So basically you build the M2 model (=UML) from Java and and then map this to XML with XMI if I understand this correctly (and I think the double indirection is why you don't find good resources for the mapping from UML to XMI directly).
For many people, examples may be more accessible than the chain of transformation rules defined by the various OMG standards. So I'd just draw a minimal UML example diagram in my favorite UML tool for the export aspect I am interested in and look at the exported XMI. Then add features as needed...
P.S.: You may want to use the Java reflection classes (package java.lang.reflect) instead of parsing the the Java source yourself to generate XMI (if you don't need to preserve method argument names).

Using [java.util] and [java.lang] in c# using ikvm

I am trying to access a java class via C# and I am not sure on how to pass the required parameters to instantiate it.
I need to pass an object of type [java.util.Properties] to the constructor and I need your inputs on which jar/java class files I need to convert to dll using IKVM..
From the java implementation, it looks like I need to include java.util.dll and java.lang.dll. Any help will be appreciated!
Kindly let me know if the above description is not clear!!
I had to reference IKVm.OpenJDK.Core.dll in my c# project to start using java.util.Properties.
If you want work with IKVM then you need ever IKVM.OpenJDK.Core.dll. See also in the wiki.

Using Jaxab SchemaGen

i am working on Jaxb 2.x and able to unmarshel XML doc in to Java component but when i am trying to create schema from my existing java classes its not working.
i have gone through the various site with the help of Google but till now not able to get success,if any one have used this functionality in the past or using it can help me how to achieve this.
Thanks in advance
Here is an example of generating an XML schema from Java classes:
http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JAXB/GenerateSchema
After long try i am able to generate XSD based on POJO using JAXB schemagen.In my main class based on which i was trying to generate XSD was refereeing some other classes which was in other packages and i was not able to figure it out how to set class path for these classes but on removing those references was able to get schemagen working will explore now how to set class path for schemagen

Categories