GNU bug report logs -
#9306
Java build errors due to trailing colon in CLASSPATH
Previous Next
Reported by: "Daniel Richard G." <skunk <at> iSKUNK.ORG>
Date: Mon, 15 Aug 2011 19:57:02 UTC
Severity: normal
Tags: patch
Done: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9306 in the body.
You can then email your comments to 9306 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:
bug#9306
; Package
automake
.
(Mon, 15 Aug 2011 19:57:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Daniel Richard G." <skunk <at> iSKUNK.ORG>
:
New bug report received and forwarded. Copy sent to
bug-automake <at> gnu.org
.
(Mon, 15 Aug 2011 19:57:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I am using Automake 1.11.1, and have recently encountered a subtle issue
that causes compilation of some Java programs to fail.
Here is a typical build failure, produced from a minimal test case I've
assembled, using OpenJDK on Ubuntu's Natty release:
make[3]: Entering directory `/tmp/automake-java-bug/org/gnu/bug'
CLASSPATH=../../..:./../../..:$CLASSPATH javac -d ../../.. Library.java Application.java
./Library.java:5: duplicate class: org.gnu.bug.Library
public class Library
^
Application.java:9: cannot access Library
bad class file: RegularFileObject[./Library.java]
file does not contain class Library
Please remove or make sure it appears in the correct subdirectory of the classpath.
Library lib = new Library();
^
2 errors
make[3]: *** [classdist_noinst.stamp] Error 1
If I copy-and-paste the javac invocation, edit it slightly, and run
it...
env CLASSPATH=../../..:./../../..: javac -d ../../.. Library.java Application.java
...I get the same error. However, if I remove that trailing colon from
CLASSPATH, and try it again...
env CLASSPATH=../../..:./../../.. javac -d ../../.. Library.java Application.java
...compilation succeeds. If I invoke the above build with
env CLASSPATH=/does-not-exist make
then compilation likewise succeeds.
Note that I do not have CLASSPATH set in my environment. It would appear
that a trailing colon in the CLASSPATH environment variable has a
special meaning attached to it, which makes Automake's use of
CLASSPATH=mumblemumble:$$CLASSPATH in makefiles problematic.
(The straightforward solution would be to replace that construct with
CLASSPATH=mumblemumble$${CLASSPATH:+:$$CLASSPATH}, but whether all
shells can handle that is an open question.)
Attached is a tarball containing the minimal test case.
--Daniel
P.S.: Please Cc: any replies to me, as I am not subscribed to this list.
--
NAME = Daniel Richard G. _\|/_ Remember, skunks
MAIL = skunk <at> iSKUNK.ORG (/o|o\) _- don't smell bad---
MAIL+= skunk <at> alum.MIT.EDU < (^),> it's the people who
WWW = (not there yet!) / \ annoy us that do!
[automake-java-bug.tar.gz (application/x-gzip, attachment)]
Information forwarded
to
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:
bug#9306
; Package
automake
.
(Tue, 16 Aug 2011 13:34:01 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Daniel, thanks for the report.
On Monday 15 August 2011, Daniel Richard wrote:
> I am using Automake 1.11.1, and have recently encountered a subtle issue
> that causes compilation of some Java programs to fail.
>
> Here is a typical build failure, produced from a minimal test case I've
> assembled, using OpenJDK on Ubuntu's Natty release:
>
> make[3]: Entering directory `/tmp/automake-java-bug/org/gnu/bug'
> CLASSPATH=../../..:./../../..:$CLASSPATH javac -d ../../.. Library.java Application.java
> ./Library.java:5: duplicate class: org.gnu.bug.Library
> public class Library
> ^
> Application.java:9: cannot access Library
> bad class file: RegularFileObject[./Library.java]
> file does not contain class Library
> Please remove or make sure it appears in the correct subdirectory of the classpath.
> Library lib = new Library();
> ^
> 2 errors
> make[3]: *** [classdist_noinst.stamp] Error 1
>
>
> If I copy-and-paste the javac invocation, edit it slightly, and run
> it...
>
> env CLASSPATH=../../..:./../../..: javac -d ../../.. Library.java Application.java
>
> ...I get the same error. However, if I remove that trailing colon from
> CLASSPATH, and try it again...
>
> env CLASSPATH=../../..:./../../.. javac -d ../../.. Library.java Application.java
>
> ...compilation succeeds. If I invoke the above build with
>
> env CLASSPATH=/does-not-exist make
>
> then compilation likewise succeeds.
>
> Note that I do not have CLASSPATH set in my environment. It would appear
> that a trailing colon in the CLASSPATH environment variable has a
> special meaning attached to it, which makes Automake's use of
> CLASSPATH=mumblemumble:$$CLASSPATH in makefiles problematic.
>
> (The straightforward solution would be to replace that construct with
> CLASSPATH=mumblemumble$${CLASSPATH:+:$$CLASSPATH}, but whether all
> shells can handle that is an open question.)
>
Luckily, as far as I know, the above construct should be portable to all
non-museum shells. So I've used it with only a minor modification (with
the only purpose of making the contruct slighlty clearer):
CLASSPATH=mumblemumble$${CLASSPATH:+":$$CLASSPATH"}
> Attached is a tarball containing the minimal test case.
>
I can reproduce the problem using your test case, and fix it using your
suggestion. I've preparad the attached patch, which I will push in a
couple of days if there are no further comments.
BTW, are you the same "Daniel Richard G." listed in THANKS with the address
"danielg <at> teragram.com"? If yes, should I update your address there?
Thanks,
Stefano
[0001-java-avoid-compilation-errors-when-CLASSPATH-is-empt.patch (text/x-patch, inline)]
From 7f1cf56ba7d1b36fb4c9464f8ed7d10ad44e65a9 Mon Sep 17 00:00:00 2001
Message-Id: <7f1cf56ba7d1b36fb4c9464f8ed7d10ad44e65a9.1313501403.git.stefano.lattarini <at> gmail.com>
From: Daniel Richard G <skunk <at> iskunk.org>
Date: Tue, 16 Aug 2011 15:19:14 +0200
Subject: [PATCH] java: avoid compilation errors when CLASSPATH is empty
* lib/am/java.am (CLASSPATH_ENV): When redefining `$CLASSPATH',
do not append an empty component in case the previous value of
CLASSPATH is empty or unset.
* tests/java-empty-classpath.test: New test.
* tests/Makefile.am (TESTS): Update.
Fixes automake bug#9306.
---
ChangeLog | 11 +++++
lib/am/java.am | 2 +-
tests/java-empty-classpath.test | 90 +++++++++++++++++++++++++++++++++++++++
3 files changed, 102 insertions(+), 1 deletions(-)
create mode 100755 tests/java-empty-classpath.test
diff --git a/ChangeLog b/ChangeLog
index af2556f..c9ce830 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-08-16 Daniel Richard G. <skunk <at> iskunk.org> (tiny change)
+ Stefano Lattarini <stefano.lattarini <at> gmail.com>
+
+ java: avoid compilation errors when CLASSPATH is empty
+ * lib/am/java.am (CLASSPATH_ENV): When redefining `$CLASSPATH',
+ do not append an empty component in case the previous value of
+ CLASSPATH is empty or unset.
+ * tests/java-empty-classpath.test: New test.
+ * tests/Makefile.am (TESTS): Update.
+ Fixes automake bug#9306.
+
2011-08-08 Stefano Lattarini <stefano.lattarini <at> gmail.com>
test defs: more environment cleanup
diff --git a/lib/am/java.am b/lib/am/java.am
index d6eb455..604df22 100644
--- a/lib/am/java.am
+++ b/lib/am/java.am
@@ -21,7 +21,7 @@
## ---------- ##
JAVAC = javac
-CLASSPATH_ENV = CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH
+CLASSPATH_ENV = CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT)$${CLASSPATH:+":$$CLASSPATH"}
JAVAROOT = $(top_builddir)
class%DIR%.stamp: $(%DIR%_JAVA)
diff --git a/tests/java-empty-classpath.test b/tests/java-empty-classpath.test
new file mode 100755
index 0000000..230bb7c
--- /dev/null
+++ b/tests/java-empty-classpath.test
@@ -0,0 +1,90 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Java compilation works also when CLASSPATH is unset or empty at
+# compilation time. See automake bug#9306.
+
+required=javac
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AC_CONFIG_SRCDIR([org/gnu/bug/Library.java])
+AC_CONFIG_FILES([
+ org/Makefile
+ org/gnu/Makefile
+ org/gnu/bug/Makefile
+])
+AC_OUTPUT
+END
+
+mkdir org org/gnu org/gnu/bug
+cat > Makefile.am <<END
+CLEANFILES = *.class
+SUBDIRS = org
+END
+echo SUBDIRS = gnu > org/Makefile.am
+echo SUBDIRS = bug > org/gnu/Makefile.am
+cat > org/gnu/bug/Makefile.am <<'END'
+JAVAROOT = ../../..
+dist_noinst_JAVA = Library.java Application.java
+END
+
+cat > org/gnu/bug/Library.java <<'END'
+package org.gnu.bug;
+public class Library
+{
+ public Library ()
+ {
+ // Nothing to do.
+ }
+ public static void doSomethingUseful (String arg)
+ {
+ System.out.println (arg);
+ }
+}
+END
+
+cat > org/gnu/bug/Application.java <<'END'
+import org.gnu.bug.*;
+public class Application
+{
+ public static void main (String args[])
+ {
+ Library lib = new Library ();
+ lib.doSomethingUseful ("PLUGH");
+ }
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+unset CLASSPATH || :
+$MAKE
+$MAKE clean
+
+CLASSPATH=''; export CLASSPATH
+$MAKE
+$MAKE clean
+
+unset CLASSPATH || :
+$MAKE distcheck
+
+:
--
1.7.2.3
Information forwarded
to
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:
bug#9306
; Package
automake
.
(Tue, 16 Aug 2011 13:34:02 GMT)
Full text and
rfc822 format available.
Added tag(s) patch.
Request was from
Stefano Lattarini <stefano.lattarini <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Tue, 16 Aug 2011 17:04:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:
bug#9306
; Package
automake
.
(Tue, 16 Aug 2011 19:13:01 GMT)
Full text and
rfc822 format available.
Message #16 received at submit <at> debbugs.gnu.org (full text, mbox):
On Tue, 2011 Aug 16 15:30+0200, Stefano Lattarini wrote:
>
> Luckily, as far as I know, the above construct should be portable to
> all non-museum shells. So I've used it with only a minor modification
> (with the only purpose of making the contruct slighlty clearer):
>
> CLASSPATH=mumblemumble$${CLASSPATH:+":$$CLASSPATH"}
The extra clarity is appreciated; I'm still not used to doing these
special variable dereferences :-)
> I can reproduce the problem using your test case, and fix it using
> your suggestion. I've preparad the attached patch, which I will push
> in a couple of days if there are no further comments.
The patch works for me, and I defer to you on older shells being able to
handle this.
> BTW, are you the same "Daniel Richard G." listed in THANKS with the
> address "danielg <at> teragram.com"? If yes, should I update your
> address there?
The same! That's my work address, and while it remains active, my
personal address (@iskunk.org) is the one I usually go by in this realm.
Please feel free to update the entry.
Regards,
--Daniel
--
NAME = Daniel Richard G. _\|/_ Remember, skunks
MAIL = skunk <at> iSKUNK.ORG (/o|o\) _- don't smell bad---
MAIL+= skunk <at> alum.MIT.EDU < (^),> it's the people who
WWW = (not there yet!) / \ annoy us that do!
Information forwarded
to
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:
bug#9306
; Package
automake
.
(Tue, 16 Aug 2011 19:13:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:
bug#9306
; Package
automake
.
(Wed, 17 Aug 2011 07:57:01 GMT)
Full text and
rfc822 format available.
Message #22 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tuesday 16 August 2011, Daniel Richard wrote:
> On Tue, 2011 Aug 16 15:30+0200, Stefano Lattarini wrote:
> > BTW, are you the same "Daniel Richard G." listed in THANKS with the
> > address "danielg <at> teragram.com"? If yes, should I update your
> > address there?
>
> The same! That's my work address, and while it remains active, my
> personal address (@iskunk.org) is the one I usually go by in this realm.
> Please feel free to update the entry.
>
OK, will do with the attached trivial patch.
Thanks,
Stefano
[0001-THANKS-Daniel-Richard-G.-Update-e-mail-address.patch (text/x-patch, inline)]
From 4eed80c1b8684ce924163f9b3aaae98ac6b3826e Mon Sep 17 00:00:00 2001
Message-Id: <4eed80c1b8684ce924163f9b3aaae98ac6b3826e.1313567598.git.stefano.lattarini <at> gmail.com>
From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Date: Wed, 17 Aug 2011 09:53:07 +0200
Subject: [PATCH] * THANKS (Daniel Richard G.): Update e-mail address.
---
ChangeLog | 4 ++++
THANKS | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c9ce830..a124259 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-08-17 Stefano Lattarini <stefano.lattarini <at> gmail.com>
+
+ * THANKS (Daniel Richard G.): Update e-mail address.
+
2011-08-16 Daniel Richard G. <skunk <at> iskunk.org> (tiny change)
Stefano Lattarini <stefano.lattarini <at> gmail.com>
diff --git a/THANKS b/THANKS
index 3d71419..d91c5bb 100644
--- a/THANKS
+++ b/THANKS
@@ -67,7 +67,7 @@ Dalibor Topic robilad <at> kaffe.org
danbp danpb <at> nospam.postmaster.co.uk
Daniel Jacobowitz drow <at> false.org
Daniel Kahn Gillmor dkg <at> fifthhorseman.net
-Daniel Richard G. danielg <at> teragram.com
+Daniel Richard G. skunk <at> iskunk.org
Dave Brolley brolley <at> redhat.com
Dave Korn dave.korn.cygwin <at> googlemail.com
Dave Morrison dave <at> bnl.gov
--
1.7.2.3
Information forwarded
to
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:
bug#9306
; Package
automake
.
(Wed, 17 Aug 2011 07:57:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Stefano Lattarini <stefano.lattarini <at> gmail.com>
:
You have taken responsibility.
(Thu, 18 Aug 2011 19:31:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
"Daniel Richard G." <skunk <at> iSKUNK.ORG>
:
bug acknowledged by developer.
(Thu, 18 Aug 2011 19:31:03 GMT)
Full text and
rfc822 format available.
Message #30 received at 9306-done <at> debbugs.gnu.org (full text, mbox):
On Wednesday 17 August 2011, Stefano Lattarini wrote:
> On Tuesday 16 August 2011, Daniel Richard wrote:
> > On Tue, 2011 Aug 16 15:30+0200, Stefano Lattarini wrote:
> > > BTW, are you the same "Daniel Richard G." listed in THANKS with the
> > > address "danielg <at> teragram.com"? If yes, should I update your
> > > address there?
> >
> > The same! That's my work address, and while it remains active, my
> > personal address (@iskunk.org) is the one I usually go by in this realm.
> > Please feel free to update the entry.
> >
> OK, will do with the attached trivial patch.
>
I've pushed both the patches now, and I'm closing the bug report.
Thanks,
Stefano
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 16 Sep 2011 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 284 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.