The source distribution of the Java Embedding Plugin is a "project"
that was created using XCode 2.5 on OS X 10.4.11 (Tiger). XCode
version 2.5 or greater is required to build it. Choose "Build" from
the "Build" menu. The binary
(JavaEmbeddingPlugin.bundle
) will be in
the build/Release
subdirectory, and will be a universal
binary (supporting both ppc and i386 Macs).
Doing this is rather a pain, because you first have to build
Mozilla itself from source. The MRJ Plugin JEP derives from source
for the MRJ Plugin Carbon included with Mozilla 1.6's source tarball.
But pretty much any recent version of Firefox, Seamonkey or Camino
will do. Source tarballs for released Firefox versions are available
at
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/, in
the source
subdirectory for the specific release whose
source you want. Good build instructions (including for Mac OS X) are
available at
http://developer.mozilla.org/en/docs/Build_Documentation.
Note that your .mozconfig
file needs to make the
Objdir
the top level directory -- otherwise you'll get
lots of warnings about missing files. This isn't what Mozilla.org's
build instructions recommend, so you probably won't be able to use a
build you've already made.
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@
Note also that you won't be able to use recent "trunk" (aka mozilla-central) builds: The MRJ Plugin Carbon has been removed from these builds, along with APIs that it needs to run.
The MRJ Plugin Carbon exists in
the plugin/oji/MRJCarbon
subdirectory. It doesn't get
built when you build Mozilla. To build it with my additions and
corrections, you need XCode 2.5 or greater.
My source distribution also includes a patch file, but that's just for reference.
MRJPlugin.xcodeproj
project in the
plugin/oji/MRJCarbon/plugin
directory and double-click
on it.
Don't open the old MRJPlugin.pbproj
project -- doing
so may overwrite the new MRJPlugin.xcodeproj
project.
The binary (MRJPlugin.plugin
) will be in the
plugin/oji/MRJCarbon/plugin/build/Release
directory, and will be a universal binary (supporting both ppc and
i386 Macs).
/System/Library/Frameworks/AppKit.framework/AppKit
)
and AWT's Java native library
(/System/Library/Frameworks/JavaVM.framework/Libraries/libawt.jnilib
).
You might also want to take a look at the WebKit framework
(/System/Library/Frameworks/WebKit.framework/WebKit
).
Apple releases source for most (though not all) of the WebKit
at http://webkit.org/.
Class-dump is available at http://www.codethecode.com/projects/class-dump/.
nm -pm
(or nm -pam
)
I'm not sure whether nm
(which is a mnemonic for
"name") is included with a standard OS X installation, or whether
you need to install one of the Developer Toolkits. It displays the
symbols in an executable or library. The two nm
parameters that I find most useful are -p
(which
causes the symbols to be displayed in the order in which they occur
in the binary) and -m
(which makes nm
use
a more verbose display for Cocoa symbols, like that used by
class-dump). (Symbols that appear together in the binary are often
used together in the code. The -p
parameter preserves
this information.)
This program claims to be able to "decompile" Java classes to a human-readable form of bytecode or "disassemble" them to Java source code. (Odd terminology -- the reverse of what you would expect.) I've only ever been able to get it to "decompile" to bytecode -- but that's still extremely useful.
One serious limitation is that JReversePro (which hasn't been
updated for a while) can't read .class
files created
by J2SE 5.0/1.5's javac
compiler. But JAD (see next
item) can usually do a pretty good job of this ... though it's also
quite old, and can't ready any Java-1.5-specific (or even
Java-1.4-specific) structures.
JReversePro is a Sourceforge project, available at http://jrevpro.sourceforge.net/.
This program can either disassemble Java classes to human-readable bytecode or decompile them to Java source code.
Inevitably, its decompilation to source code isn't always
totally correct. And (because it's quite old) it doesn't
understand Java-1.5-specific (or even Java-1.4-specific) structures
in .class
files. (As far as I know I've never
encountered any such structures, so this seems not to be a serious
problem.)
But unlike JReversePro it doesn't refuse to work
on .class
files created by an unsupported versions of
javac
. And it's much easier to use JAD to
disassemble/decompile many .class
files at once.
JAD's last home page of record is http://www.kpdus.com/jad.html -- which is no longer accessible. Fortunately Tomas Varaneckas has created a mirror from which many of the downloads are still available (http://www.varaneckas.com/jad).
The locus classicus for deciphering Java bytecode is chapter 6 of Sun's Java Virtual Machine Specification. I've also found the "Java Virtual Machine Online Instruction Reference" very useful. If you don't find it at this URL, do a Google search on its title.
Sun makes available the full source code for its JVM. The license used to be very restrictive -- practically speaking it prevented you from making any changes or (presumably) from using any of it in your code. Sun is now in the process of adopting the GPL. But whatever the license terms, this source code is extremely useful as a reference for Sun's undocumented classes. Apple's JVM isn't identical to Sun's (which is why you also need to see Apple's Java bytecode). But it's often very close.