Where to find Java 6 JSSE/JCE Source Code? - java

Where can I download the JSSE and JCE source code for the latest release of Java? The source build available at https://jdk6.dev.java.net/ does not include the javax.crypto (JCE) packages nor the com.sun.net.ssl.internal (JSSE) packages.
Not being able to debug these classes makes solving SSL issues incredibly difficult.

there: openjdk javax.net in the security group
src/share/classes/javax/net
src/share/classes/com/sun/net/ssl
src/share/classes/sun/security/ssl
src/share/classes/sun/net/www/protocol/https
also on this page:
src/share/classes/javax/crypto
src/share/classes/com/sun/crypto/provider
src/share/classes/sun/security/pkcs11
src/share/classes/sun/security/mscapi
These directories contain the core
cryptography framework and three
providers (SunJCE, SunPKCS11,
SunMSCAPI). SunJCE contains Java
implementations of many popular
algorithms, and the latter two
libraries allow calls made through the
standard Java cryptography APIs to be
routed into their respective native
libraries.

I downloaded the src jar from: http://download.java.net/jdk6/source/
NOTE:
This is a self extracting jar, so just linking to it won't work.
... and jar -xvf <filename> won't work either.
You need to: java -jar <filename>
cheers,
jer

if you just want read the source code:
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/security/ssl/SSLSocketImpl.java

While this doesn't directly answer your question, using the javax.net.debug system property has helped me sort through SSL issues. -Djavax.net.debug=all pretty much gives you everything in gory detail. Documentation on this is at JSSE Debugging Utilities.
One note: I've seen that on Java 1.4 and maybe 1.5 levels, the output with option "all" is not as complete as it is using the same option on the Java 1.6 level. E.g., 1.6 shows the actual contents of network (socket) reads and writes. Maybe some levels of 1.4 and 1.5 do as well, but 1.6 was more consistent.

For some unknown reason Orcale doesn't released source.jar and javadocs jar for JSE.
I found only one place where you can find them http://jdk7src.sourceforge.net/ but it's outdated and unofficial.
The only one way is to clone OpenJDK repository

Put Jad on your system path. Install JadClipse plugin for Eclipse. Use the force, read the decompiled source. :-)

Related

Paired JAR and native library binaries for SVN Java bindings (JavaHL) on Windows?

I'm writing some code that uses the Subversion (SVN) Java bindings (JavaHL) directly (where JavaHL comprises native libraries and a thin Java wrapper). On Linux (Ubuntu 12.04) this is no problem: package libsvn-java installs the native libraries and \usr\share\java\svn-javahl.jar, so i just reference the latter and away I go.
On Windows, I know of no such clean packaging of the pair (JAR + native libraries) together. I was aware that SlikSVN contains a JavaHL implementation, but installing that seems only to install the native libraries (which it does put on the PATH). Is there anything that gives a clean package of the two? (If SlikSVN does package the JAR, it's in no place I expect, and a search of the whole drive finds nothing...)
As a workaround, I built the JAR file manually (details below which may be useful for people). But it seems that the 'match' of Java wrapper and native libraries is very precise: when I built a JAR from later SVN source code (instead of that matching my exact SlikSVN SVN version) as a test, I got fatal errors in the native code (EXCEPTION_ACCESS_VIOLATION). Perhaps I was unlucky but, if it is pretty sensitive, I'll need to provide a JAR library for every potential version of SlikSVN (and thus SVN) that users might install (or restrict their SlikSVN choices, or have some prone-to-error auto-build process which would need them to install a JDK). All bad options :-(
Manual Workaround (Bad!)
I had SlikSVN 1.8.10: svn --version reports version 1.8.10-SlikSvn-1.8.10-X64.
So I got the Java wrapper source from the tagged SVN release. (You can also get it from the
main site's source downloads.)
svn export http://svn.apache.org/repos/asf/subversion/tags/1.8.10/subversion/bindings/javahl/src
Compiling this (there are no dependencies) into a JAR, and using that, worked fine with the SlikSVN native libraries.
P.S. I know that I could use SVNKit to avoid having to do this, but I'm doing this precisely so as not to rely on SVNKit for licensing reasons (plus the JavaHL API is fine and reasonably high-level anyway, and there are other reasons to prefer using the 'official' native JavaHL implementation).
The WANdisco binaries should have JavaHL in them.
http://www.wandisco.com/subversion/download
Been a while since I used them myself (don't typically use Windows). But WANdisco has tools that depend on JavaHL so I can't imagine the Windows binaries are missing JavaHL.
[Question author edit to complete detail]
You need to install the (Windows) Subversion client (not SmartSVN), and make sure you check the box to add it to the Windows PATH. This stores the 'paired' JAR in the install directory (along with the native libraries). However, WANDisco only provide a 32-bit install (see this forum post) so this won't work on 64-bit Windows. In addition, the JAR only includes the Apache versions of the API, which were added for Subversion 1.7. If you're using the legacy org.tigris.subversion.javahl package API for compatibility with pre-1.7 SVN clients, you still need to build the JAR manually.

Run Java packages on unsupported Java Version

I have a PowerMac and it is giving me bad version number on some .jars. I would love to make it seem like I am running Java 6. How would I spoof the version? Let me also say I am running PowerPC and Leopard
The most likely problem is that you have Java 6 JAR files and you are trying to run them on an old Java installation.
How would I spoof the version?
The answer to your question is that you can't. The way to run Java 6 specific JAR files it to use a Java 6 (or later) JRE or JDK.
The problem is that the format of Java class files has changed, and your installation can't cope with the new format. And this is not a gratuitous change that you can pretend doesn't exist. Java 6 (actually Java 5) has support for generic types, enums, annotations and other things. Assuming that the JARs contain code that uses these new language features, an older JRE simply won't know what to do with them.
There are two solutions:
Upgrade your Java installations to the required level on all machines. This is the best solution ... if it is an option ... because it means your users will get the benefit of security and bug fixes and performance enhancements. (And progress of your project won't be held back by the constraint of supporting legacy platforms.)
Compile all of your code for compatibility with the oldest version of Java that you still have to use. Either compile on the corresponding old JDK, or on a more recent JDK using appropriate -source / -target / -Xbootclasspath options ... as described by the javac manual page.
The catch with the second solution is that if the source code for the JAR files in question uses recently added Java language features or APIs, then recompiling for the older platform will fail. To fix this you will need to rewrite your code to replace the nice modern stuff with archaic stuff. Not a good solution, IMO.
The other possibility is that you are seeing corrupted JAR files. This is unlikely, but it can happen if you are using applets or webstart, and the server is delivering error pages instead of JAR files.
The third possibility is that you simply haven't configured your Mac's Java installation's correctly. Making Java 7 the default should allow you to run everything without class version problems. (Thanks #paulsm4) Note that I can't help you with that ... 'cos I don't use Java on a Mac.

com.sun.awt package usage

I found a java code and want to use it in my project. It contains these imports that my JDK does not have :
import com.sun.awt.AWTUtilities;
import com.sun.jna.Native;
import com.sun.jna.platform.WindowUtils;
I referred to sun site and found this download page :
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Is it necessary to download all JDK and JRE and replace it from SUN website? My JDK is version 6 and is up to date.
Thank you all
JNA is an additional library and not part of the standard api, you have to download it (here) and include it in your classpath.
The AWTUtilities class is only distributed with the sun jvm as an implementation detail of the api and as such subject to change, this can break any program depending on it (if possible don't use it).
WindowUtils can be found in the platform.jar, you it can find it on the same page as jna.
Your JDK should have com.sun.awt.AWTUtilities. It is in rt.jar.
Maybe the problem (for that file) is that your IDE excludes the parent the build path ... on the grounds that it is a bad idea to use those classes directly.
The com.sun.jna classes are not in rt.jar. They apparently may be found in a jna.jar, though I haven't yet found a good place to download it from. (If you use Maven, try this.)
You should not use any com.sun packages except as a last resort. These are considered to be implementation details, and they are not part of the JDK API. They can change arbitrarily between versions, so they can cause problems when you try to upgrade JDK versions.
The com.sun classes are almost always wrapped by "official" classes - you should use those instead. You can use these in a last resort situation, but they are already part of the JDK download, so there should be no extra downloading necessary.
EDIT: Looks like you're right, you do need to download some extra jars. The JNA jar is available on maven central (http://mvnrepository.com/artifact/com.sun.jna/jna/3.0.9). Especially if this is a code snippet you found, I would highly advise against using com.sun packages directly.

How to find native instructions generated from class file

I would like to learn what native instructions Java's JIT compiler generates when it loads a class file. Is there any way of knowing it?
I am working in Linux on a 586 processor. And I am using Sun's JDK 1.6 update 21. Is there any tool that I can use to find out what I am looking for?
You probably need -XX:+PrintOptoAssembly, but you'd need a debug build of the JVM. The links to the binary distributions seem not to be available any longer, so you might have to build it from source: http://download.java.net/jdk6/6u10/archive/
If you're planning to try this with OpenJDK 7 as well, this might be of interest:
http://wikis.sun.com/display/HotSpotInternals/PrintAssembly

Source code for the Java library classes

Where can I find the source code for the Java library classes? I mean classes in rt.jar.
Platform: Windows.
For old versions of Java with separate JRE and JDK downloads, download the JDK. The sources for the public classes are in src.zip.
Here's the browsable source code for OpenJDK 7.
Update: As of June 2018 grepcode seems to be down. Here you can find an alternative.
Update^2: As of October 2020, the two previous links do not work. View it at OpenJDK and vote up the answer by Nosrep, which I got it from.
Sources are in src.zip located in the installation folder:
On Windows, the JDK includes src.zip by default if I remember well.
On a Linux distro, you may have to install the sun-java6-source package.
On Mac, you'll have to download the Developer Documentation. Have a look at this answer.
If you only need to have a look at the source/implemenation, i would suggest using
Docjar
Edit
GrepCode is even better
GrepCode
You can directly browse the code online here for Java : https://zgrepcode.com/java/openjdk/10.0.2/
It is a great tool also for browsing most of the open source projects as it gives you internal linking to classes.
As almost all the suggestions seem to be either grepcode or zgrepcode which are both down, I found one from OpenJDK here: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/tip/src/share/classes/
Edit: a more complete version of all OpenJDK projects and JDK 6-15 can be found here: https://hg.openjdk.java.net/
As mention above, most of the source files can be found by downloading the SDK.
However for some classes you can find the source code (javax.ssl etc') for I suggest adding the jad eclipse plugin that will decompile any class without using external site such as Docjar.
Jad eclipse info:
http://jadclipse.sourceforge.net/wiki/index.php/Main_Page
There is also grepcode.com (not sure how old this site is, perhaps this answer is an update for new solutions now), sample query:
http://grepcode.com/search?query=java.lang.Math.sin&start=0&entity=type&n=

Categories

Resources