• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading the JDK6 code

 
Ranch Hand
Posts: 54
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i have years of experience in Java. Yet, the code for the language has been daunting and so I have avoided for some time until now. I'm reading the code for JDK6, but I have it some problems in my understanding of it. Anyone here have experience with the code for JDK? If you do, would you be kind enough to give me a brief explanation of the code?

Also I don't understand how this piece of code works.
This is from make/common/shared/Defs-utils.gmk.



I am semi fluent in shell, but I never heard of the 'call' command, and I have already tried googling it, but to no avail. Also i don't know where PrefixPath is defined. Is it a shell function? But I can't find it.
 
Saloon Keeper
Posts: 7582
176
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been programming Java for 22 years, and never felt the urge to dig into the source code (aside from the Java source of the class libraries) - kudos for that!

.gmk sounds like Gnu make to me (just a guess) - maybe consult the man page for that.
 
William Ng
Ranch Hand
Posts: 54
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, congratulations for being a Java sage. Thats a lot of time programming!
Now about the code. Understandably, I get why one would not want to spend their time wading through the non-class library code of Java. It's written in half C, so it has probably left half of Java developers, especially newcomers, in the dust already. Then another another part in Shell. In other words, it's pretty scary. But I am really want to learn for educational purposes and to get more invovled with the development community for the language. So, I thought, hey, why not start here. I am determined to learn the code base.

In fact, I actually ended up search for '$(call' in the search bar, and that turned up exactly what I was looking for (https://www.gnu.org/software/make/manual/make.html#Call-Function). It's part of make. I originally thought it was, but after a futile search I changed my mind. But I guess I was right after all.

Thanks for the reply. Though. I always appreciate the first responders who have the courage to post, especially for a unsure topic.
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I speculated it might be Gnu make, and it turned out to be - so it was a good guess :-)
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When Java was first written, the platform was Sun's Solaris, which is a BSD Unix. I suspect that originally it used Unix make rather than gmake.

The JDK, of course, consists of a complex set of programs, libraries and classfiles. So a full build is not a trivial thing to do. Depending on one's interests, I'd say that most people would start by either looking at the source for the javac compiler or the java JVM. The JVM at its heart is fairly simple - it's a bytecode interpreter, so mostly it looks up bytecodes and executes them and each individual bytecode is usually a fairly simple function. Where it gets exciting is when you layer on JVM security, add a garbage collector and ramp it up with a JIT bytecode compiler.

I don't know if compiler writing is as studied as it used to be. Back in the 80's I used YACC to build C++ and the Purdue Compiler Construction Toolset (PCCTS) along with my trusty copy of Aho and Ullman's "Dragon Book" on compiler design. PCCTS consisted of several programs, but as time progressed, they mostly got folder into antlr and antlr was re-written in Java. Whether javac was written with antlr, yacc/bison or even brute force, I've never checked. I did use antlr when I did a partial write of a java compiler back in the mid 1990s, though.

I congratulate you on your diligence, William, and I think it deserves a cow. And please note that there is an open-source implementation of Java (IcedTea) and they would almost certainly welcome a little extra help keeping that project going.
 
William Ng
Ranch Hand
Posts: 54
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Tim
Is there a difference between unix make and gmake?

Thanks for your suggestion. Thinking more about it now, the JVM and javac would be closer to the core of Java. I will probably try that next.

And i'll definitely check out IceTea. Thanks. You deserve a cow too! How do you gives cows anyways?




 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Ng wrote:. . . Is there a difference between unix make and gmake?. . .

Don't know, but this link suggest there isn't much difference.
 
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Ng wrote:You deserve a cow too! How do you gives cows anyways?


I have granted on your behalf.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main difference between gmake and make is that gmake has more fancy features. The original Unix make was OK for automated compiling and linking of C and assembly code, but gmake added features that made it more convenient. Fewer, shorter (and more cryptic rules), conditional operations in the build process, stuff like that.

Make/gmake is often assisted in the build process. The "configure" tool can be used to check to see if all of the build dependencies are present in the system and to construct a makefile. Here dependencies aren't just libraries, it also checks to see if certain tools are installed, and it does things like check the compiler being used to make sure that certain features are supported. Unlike, say, Maven, the configure utility does not attempt to resolve dependencies, just make sure that they are satisfied. Then there are the "make makers", such as cmake, which help generate makefiles.

There's a classic triad of commands used to build many of the Linux applications and libraries. It goes like this:
Often people will use the "tee" command on the make stage so that build output not only displays on the console, but also gets recorded to a log file.
 
William Ng
Ranch Hand
Posts: 54
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:

William Ng wrote:You deserve a cow too! How do you gives cows anyways?


I have granted on your behalf.



Thanks Liutauras.

Hi, Tim.

Thanks for wonderful explanation. I have used make before, but I didn't know the details you stated, but I do now. So since the JDK uses make, then it's probably written in C. So how much of OpenJDK would you estimate is written in C?
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OpenJDK is a very large project, so it's hard to say. Generally you want as much of a language environment to be native to that language as possible, but Java does have a lot of classes that have to tap into OS-specific and/or hardware-specific features (native code classes) and it's hard to write the core interpreter in Java because you've got the chicken-and-egg conundrum there. Probably the memory manager, security manager and JIT compiler have substantial native code in them as well.

OpenJDK isn't archived in git or svn like most projects. They use Mercurial. Mercurial is somewhat like git (slightly pre-dates it, I think). The command-line client program is named "hg" (chemistry fans will appreciate this). Mercurial was also used for the source archives of the Xen virtual machine manager, if memory serves.
reply
    Bookmark Topic Watch Topic
  • New Topic