Java jre source code

Where to download Java JDK source code ?

The JDK source code is inside the src.zip , this article shows you how to get it on Windows, Ubuntu (Linux) and Mac OSX.

1. Windows

In Windows, visit the Oracle website and download the JDK (not JRE).

oracle-jdk-download

Install the JDK and the src.zip is inside the JDK installed folder, for example :

 C:\Program Files\Java\jdk1.7.0_40\src.zip 

2. Ubuntu (*nix)

In Linux, for example, Ubuntu, you can get the source code from OpenJDK.

 $ apt-cache search openjdk default-jdk - Standard Java or Java compatible Development Kit default-jdk-doc - Standard Java or Java compatible Development Kit (documentation) default-jre - Standard Java or Java compatible Runtime openjdk-7-demo - Java runtime based on OpenJDK (demos and examples) openjdk-7-doc - OpenJDK Development Kit (JDK) documentation openjdk-7-jdk - OpenJDK Development Kit (JDK) openjdk-7-jre - OpenJDK Java runtime, using Hotspot JIT openjdk-7-source - OpenJDK Development Kit (JDK) source files java-package - Utility for creating Java Debian packages 
 $sudo apt-get install openjdk-7-source 

3. Mac OSX

In Mac OSX, get the JDK source code from Apple Developer, and download and install the Java for OS X Developer Package.

Later, find the source code here.

 /Library/Java/JavaVirtualMachines/$.jdk/Contents/Home/src.jar 

Источник

Java – JDK/JRE source code with matching JSSE (SSL) source code and matching runnable JDK / JRE

I have seen Where to find Java 6 JSSE/JCE Source Code?
and asked the question myself
How to get JRE/JDK with matching source? but I don’t either of these was specific enough to get the answer I was really after, so I’m going to try a way more specific version of the question.

Basically the problem that I am trying to solve is that I would like to be able to use my Eclipse debugger on Windows and step into the Java SSL classes (JSSE) to help me debug SSL issues as well as to just understand the SSL process better. BTW I am familiar with (and use) the javax.net.debug=ssl|all system property to get SSL tracing and, while this is very helpful, I’d still like to be able to step through that pesky code.

So what I think I specifically need is:

  1. An executable JRE / JDK implementation (not wanting to build one)…
  2. That runs on my Windows platform (XP)…
  3. That includes source…
  4. And that source includes the SSL «bits» (JSSE, etc.)…
  5. And ideally the SSL implementation is Sun’s or the OpenJDK version.

I think the closest thing (as noted in PW’s answer StackOverflow: 87106) is the OpenJDK source openjdk-6-src-b12-28_aug_2008.tar.gz found at OpenJDK 6 Source Release, but I’m not sure there’s a matching executable JDK / JRE for that that would run on Windows.

Best Solution

Steps to create a source jar file for attaching to an IDE for debugging.

  1. Go a little above in the directory structure i.e. to http://hg.openjdk.java.net/jdk8u/jdk8u-dev/jdk/file/4d6c03fb1039/src/share/classes/ repo.
  2. Download the source package by clicking on the «zip» or «gz» links that you see at the left pane.
  3. But this package is huge and contains thousands of *.java files. You do not normally want all of these to just debug jsse.jar code.
  4. So better copy only the sun.security.rsa , sun.security.ssl , sun.security.provider & com.sun.net.ssl packages to a new folder (lets say jsse-code) on your computer.
  5. Go to that folder from command line & create the source jar on your own.
    e.g. jar -cvf jsse-src.jar *
  6. You are done. You now have your jsse source lib that you can attach to your preferred IDE (e.g. — Eclipse) to debug the JSSE code.
Читайте также:  Document all submit javascript

Источник

Java jre source code

JRE 8 rt.jar — java.* Package Source Code

JRE 8 rt.jar is the JAR file for JRE 8 RT (Runtime) libraries. JRE (Java Runtime) 8 is the runtime environment included in JDK 8. JRE 8 rt.jar libraries are divided into 6 packages:

com.* - Internal Oracle and Sun Microsystems libraries java.* - Standard Java API libraries. javax.* - Extended Java API libraries. jdk.* - JDK supporting libraries. org.* - Third party libraries. sun.* - Old libraries developed by Sun Microsystems.
Directory of C:\fyicenter\jdk-1.8.0_191\jre\lib 63,596,151 rt.jar

Here is the list of Java classes of the java.* package in JRE 1.8.0_191 rt.jar. Java source codes are also provided.

⏎ java/time/chrono/ChronoZonedDateTimeImpl.java

/* * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ /* * * * * * * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of JSR-310 nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package java.time.chrono; import static java.time.temporal.ChronoUnit.SECONDS; import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.Serializable; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.time.temporal.TemporalField; import java.time.temporal.TemporalUnit; import java.time.zone.ZoneOffsetTransition; import java.time.zone.ZoneRules; import java.util.List; import java.util.Objects; /** * A date-time with a time-zone in the calendar neutral API. * 

* is an immutable representation of a date-time with a time-zone. * This class stores all date and time fields, to a precision of nanoseconds, * as well as a time-zone and zone offset. *

* The purpose of storing the time-zone is to distinguish the ambiguous case where * the local time-line overlaps, typically as a result of the end of daylight time. * Information about the local-time can be obtained using methods on the time-zone. * * @implSpec * This class is immutable and thread-safe. * * @serial Document the delegation of this class in the serialized-form specification. * @param the concrete type for the date of this date-time * @since 1.8 */ final class ChronoZonedDateTimeImpl implements ChronoZonedDateTime, Serializable < /** * Serialization version. */ private static final long serialVersionUID = -5261813987200935591L; /** * The local date-time. */ private final transient ChronoLocalDateTimeImpldateTime; /** * The zone offset. */ private final transient ZoneOffset offset; /** * The zone ID. */ private final transient ZoneId zone; //----------------------------------------------------------------------- /** * Obtains an instance from a local date-time using the preferred offset if possible. * * @param localDateTime the local date-time, not null * @param zone the zone identifier, not null * @param preferredOffset the zone offset, null if no preference * @return the zoned date-time, not null */ static ChronoZonedDateTime ofBest( ChronoLocalDateTimeImpl localDateTime, ZoneId zone, ZoneOffset preferredOffset) < Objects.requireNonNull(localDateTime, "localDateTime"); Objects.requireNonNull(zone, "zone"); if (zone instanceof ZoneOffset) < return new ChronoZonedDateTimeImpl<>(localDateTime, (ZoneOffset) zone, zone); > ZoneRules rules = zone.getRules(); LocalDateTime isoLDT = LocalDateTime.from(localDateTime); List validOffsets = rules.getValidOffsets(isoLDT); ZoneOffset offset; if (validOffsets.size() == 1) < offset = validOffsets.get(0); >else if (validOffsets.size() == 0) < ZoneOffsetTransition trans = rules.getTransition(isoLDT); localDateTime = localDateTime.plusSeconds(trans.getDuration().getSeconds()); offset = trans.getOffsetAfter(); >else < if (preferredOffset != null && validOffsets.contains(preferredOffset)) < offset = preferredOffset; >else < offset = validOffsets.get(0); >> Objects.requireNonNull(offset, "offset"); // protect against bad ZoneRules return new ChronoZonedDateTimeImpl<>(localDateTime, offset, zone); > /** * Obtains an instance from an instant using the specified time-zone. * * @param chrono the chronology, not null * @param instant the instant, not null * @param zone the zone identifier, not null * @return the zoned date-time, not null */ static ChronoZonedDateTimeImpl cldt = (ChronoLocalDateTimeImplreadExternal(ObjectInput in) throws IOException, ClassNotFoundException < ChronoLocalDateTime) in.readObject(); ZoneOffset offset = (ZoneOffset) in.readObject(); ZoneId zone = (ZoneId) in.readObject(); return dateTime.atZone(offset).withZoneSameLocal(zone); // TODO: ZDT uses ofLenient() > //------------------------------------------------------------------------- @Override public boolean equals(Object obj) < if (this == obj) < return true; >if (obj instanceof ChronoZonedDateTime) < return compareTo((ChronoZonedDateTime) obj) == 0; > return false; > @Override public int hashCode() < return toLocalDateTime().hashCode() ^ getOffset().hashCode() ^ Integer.rotateLeft(getZone().hashCode(), 3); >@Override public String toString() < String str = toLocalDateTime().toString() + getOffset().toString(); if (getOffset() != getZone()) < str += '[' + getZone().toString() + ']'; >return str; > >

⏎ java/time/chrono/ChronoZonedDateTimeImpl.java

Or download all of them as a single archive file:

Источник

Оцените статью