Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I'm interested in how java organizes memory and executes code (like what gets put in the stack or the heap), from the start of main, to assigning variables, calling functions, passing parameters, returning values, instantiating objects, etc. Has anyone found a good, beginner-friendly article/reference on it?
The canonical reference is the JVM spec. However, different JVMs can implement the spec in different ways. You can also check out the open source Java platform implementation, OpenJDK.
I don't know exactly how they execute their bytecode, but I found this link describing java's bytecode. I am not sure if it helps, but at least it's something to start on.
Quote:
This article gives you an understanding of Java bytecode that will enable you to be a better programmer. Like a C or C++ compiler translates source code into assembler code, Java compilers translate Java source code into bytecode. Java programmers should take the time to understand what the bytecode is, how it works, and most importantly, what bytecode is being generated by the Java compiler. In some cases, the bytecode generated is not what you expect.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Is there an Java API viewer on command line?
I have been using man for C programming and ri for Ruby programming. Both of them seems very convenient for me, and now I am looking for something alike for Java API.
I apologize if this question has been raised before. I did many Google searches but no result shows up. I think I might have been using the wrong terms.
As part of the JDK, you will also receive the javap utility that allows you to see method signatures in a java .class file.
javap myClass
For java API, you can use
javap java.lang.Integer
If you are a vi fanatic, use this tweak to see the method signature on the class under cursor with the following addition to your ~/.vimrc.
let $jre='/cygdrive/c/jdk1.6.0_21/jre'
map tt yy:tabnew ^R^W^M
map + tt:set ft=java^M!!javap -public `grep .*%$ $jre/lib/classlist`^M
Characters preceeded by caret like ^M need to be typed using Ctrl+V then Ctrl+M
javap needs to be in your system path
Use your own jre location in place of this
Finally, since this is tested using cygwin, you may need to do some touch ups
Another way is to use a text-based browser. See:
Look up javadoc Help file from Vim [Unix Only]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Ive been searching for a while and can't seem to find what im looking for. What I want to do is write a python script to report problems and enforce code standards in Java code. Everything I have found so far has been things to translate java into python or python into java and that isn't really what I want. Im looking for a python library that can parse a multi-thousand class project and present the source itself in python in such a way where I can write rules something like
every class must have class level javadoc
every class must have a #primaryContactName tag in class level javadoc
every class must have a #primaryContactEmail tag in class level javadoc
the authorized 3rd party library list is {1,2,3,4,5} are any libraries other than this
list used
all lists and maps fully type safe.
bla bla bla
I reallize that I can get a great deal of this info from javac with very little effort, and I may investigate using javac to make version work, but im looking to do something a bit more advanced where I can build in real analytics
I have done similar with XDoclet in the past, but that was primarily used to mantain metadata in the source code about what systems it was accessing and such, nothing really to this analytics level im looking for now.
Anyone come across a python library that would help out with this? I would consider other languages (java, c, etc) its simply in my current situation, python is easier to work with than anything else.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
For my java project I need to check a code written in C for errors and syntax ... Is there any API or anyother Java implementation of C syntax and error checker?
You could invoke a C compiler in Java and parse the results.
An alternative could be Ideone.com, since they offer an API.
What is ideone?
Ideone is something more than a pastebin; it's an online compiler and
debugging tool which allows to compile and run code online in more
than 40 programming languages.
That's pretty broad, but it looks like antlr might be the tool you need. There's a load of grammars available, including one for C.
Real answer:
i used to do something liek this a few years ago... basically you need JFlex and CUP or some form of a scanner/parser combo.
take a look, i don't think i have the finished thing uploaded but you can take it from there... http://code.google.com/p/javamicko/
Coco/R[1] is a LL1 compiler generator available in Java.
You can define a language by your own (tokens + syntax) and parse/check a given input.
[1] http://ssw.jku.at/Coco/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I saw the http://vmkit.llvm.org/ project but it's not quite what I'm looking for. Don't want my code to run on yet another VM but on .NET's and Java's VM.
Are there any compiler backends for LLVM that generate .NET CIL and/or Java Bytecode?
LLVM is on a much lower level than CIL and Java byte code. This means that it is difficult to map the LLVM instructions on to CIL and Java instructions, and nobody has really needed it yet so the work has not been done completely.
Some of the work has been done though. See http://llvm.1065342.n5.nabble.com/JVM-Backend-tp41356.html to see if it is useful to you.
EDIT 2020-09-03: Since this answer was written, WebAssembly has been defined which is essentially a cross platform machine language definition which runs in all major browsers and hopefully soon also natively on Linux and others. I would think that the future would be that everything distributes in this format and then is run on the appropriate virtual machine. This will most likely end the CPU wars.
C++ can be compiled to CIL (with visual C++/CLI compiler), so why not a CIL backend for LLVM?
I don't think it would be so complicated as far as the not .NET specific CIL instruction set
is quite small/simple. Compiling C++ to Java is much more complicated because there are no pointer instructions in Java's bytecode, so a Java's bytecode LLVM backend would be much more complicated.
I guess guys from MONO LLVM backend have already worked on something similar, but it seems they exploited LLVM in a different way because MONO is a C# compiler not a C++ compiler.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I need a static code analyzer for Java that produces an output file about the: relationships of the classes (also inheritance relationships), fields of the classes, method signatures, and method call hierarchies.
The important point is that the analysis data can be (easily) processed by a program. (I need the analysis for a kind of automatic "refactoring" tool for university.)
JastAdd is a good source level analyzer (and much more).
You might prefer to work on bytecode level though. This is simpler, faster, provides all information you requested, works without source (obviously) and with other JVM-based languages. For that, either Soot or ASM is a good choice.
UPDATED
Of course with bytecode you can't really perform source level refactoring (though you could do bytecode modification).
For completeness you may want to combine both approaches.