[kaffe] Bug Report - javac requires /usr/lib/rt.jar to be part of -classpath

Warwick Hunter whunter@agile.tv
Mon, 07 Oct 2002 15:32:47 +1000


This is a multi-part message in MIME format.
--------------060307040509030003090607
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

This could be considered a bug report, or it could be
considered an enhancement request.

When using the java compiler that is part of kaffe
I am constantly required to add some of the base
jars to my -classpath to avoid javac complaining
about being unable to find things like java.lang.String.
I find this quite annoying, javac should not need
this. Other Java compilers don't.

I have attached a patch against the current CVS
that adds some intelligence to javac.in so that
it checks the -classpath specified to ensure that
/usr/lib/rt.jar is part of it and if it is not
then it adds it.

Please check over this patch and tell me if you
think it is the right thing to do. If not please
advise why.

It may also make sense to add this approach to
the other scripts (java, javadoc, appletviewer).
If so let me know and I can redo the patch to
include these also.

Warwick
-- 
Warwick Hunter                    Agile TV Corporation
Voice: +61 7 5584 5912            Fax: +61 7 5575 9550
mailto:whunter@agile.tv           http://www.agile.tv

--------------060307040509030003090607
Content-Type: text/plain;
 name="kaffe-20021007-javac.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="kaffe-20021007-javac.patch"

diff -Naur kaffe/kaffe/scripts/compat/javac.in kaffe.modified/kaffe/scripts/compat/javac.in
--- kaffe/kaffe/scripts/compat/javac.in	Wed Oct 13 19:07:27 1999
+++ kaffe.modified/kaffe/scripts/compat/javac.in	Mon Oct  7 05:25:01 2002
@@ -2,5 +2,27 @@
 # We use kjc compiler rather than Sun's.
 prefix=@prefix@
 exec_prefix=@exec_prefix@
-exec @bindir@/@kaffe_TRANSF@ at.dms.kjc.Main ${1+"$@"}
+lib_path=@prefix@
+
+# Ensure that /usr/lib/rt.jar is in the classpath. 
+for opt in ${1+"$@"}; do 
+    if [ "x$classpath" == "xtrue" ]; then
+        classpath=$opt
+        continue
+    fi
+    if [ $opt == "-classpath" ]; then
+        classpath="true"
+        continue
+    fi
+    args="${args} $opt"
+done
+if [ "x$classpath" != "x" ]; then
+    echo $classpath | grep -q ${lib_path}/rt.jar
+    if [ $? -eq 1 ]; then
+        classpath=${lib_path}/rt.jar:${classpath}
+    fi
+fi
+args="${args} -classpath $classpath"
+
+exec @bindir@/@kaffe_TRANSF@ at.dms.kjc.Main $args
 

--------------060307040509030003090607--