Bug 48815 - Blank jvmargs attribute value in java task causes java.lang.NoClassDefFoundError
Summary: Blank jvmargs attribute value in java task causes java.lang.NoClassDefFoundError
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-25 11:24 UTC by daniel.hall
Modified: 2010-04-23 05:17 UTC (History)
1 user (show)



Attachments
Patch consolidating Brian's changes and Jan's testcase (6.34 KB, text/plain)
2010-04-23 05:16 UTC, Stefan Bodewig
Details

Note You need to log in before you can comment on or make changes to this bug.
Description daniel.hall 2010-02-25 11:24:01 UTC
I have spent a long time trying to assert what has been causing a NoClassDefFoundError in my build script and have finally worked out that if the jvmargs element value attribute is blank it tries to execute this value as the main class rather than the classname attribute of the java element.  There is no information or stack track because it was literally trying to execute "".  It is useful to be able to pass in arguments which may or may not be blank as a jvmarg and this functionality works in the Windows implementation.  I have found this bug to be present in Ant 1.5.0_19 and 1.7.1.

I couldn't see anything open for this at the moment, nor could I see anything in the fixes for 1.8.
Comment 1 Stefan Bodewig 2010-03-25 15:18:12 UTC
there is a patch attached t bug 43586 which is supposed to fix this.

I'm not sure whether disallowing any blank args in jvmargs would be a good thing or whether there may be any legitimate reasons to have literal blank args - like a blank classpath as companion to a -classpath argument.

Maybe we should print a warning if we encounter blank args that makes debugging such a situation easier.  This way we won't give up the flexibility we currently allow.
Comment 2 Jesse Glick 2010-03-25 16:55:32 UTC
(In reply to comment #0)
> It is useful to be able to pass in arguments which may or may not be blank as a
> jvmarg

You can use line="${possiblyBlank}". Unfortunately this assumes that ${possiblyBlank} contains no spaces. Best would be the ability to pass if/unless attrs (or nested <condition>s) on <arg> variants.
Comment 3 Antoine Levy-Lambert 2010-03-26 00:20:19 UTC
I agree with Jesse that if and unless on jvmargs, and also on <arg/> inside <exec/> and <java/> would be ideal.



Regards,

Antoine
Comment 4 Stefan Bodewig 2010-04-03 06:46:30 UTC
(In reply to comment #2)
> (In reply to comment #0)
> > It is useful to be able to pass in arguments which may or may not be blank as a
> > jvmarg
> 
> You can use line="${possiblyBlank}". Unfortunately this assumes that
> ${possiblyBlank} contains no spaces.

This is a good workaround for the current bug report.

What I meant was something different, though.  The patch attached to bug 43586 would remove all blank command line arguments and I argued this would be going too far since there might be legitimate reasons for a blank arg.

> Best would be the ability to pass
> if/unless attrs (or nested <condition>s) on <arg> variants.

Agreed.

I thought there must already be a bugzilla issue for this, but can't find one.
Comment 5 Stefan Bodewig 2010-04-23 05:16:07 UTC
Created attachment 25339 [details]
Patch consolidating Brian's changes and Jan's testcase

I have modified Brian's original change to use a linked list rather than a vector and a two-element string array rather than a map, but these changes are really minor.
Comment 6 Stefan Bodewig 2010-04-23 05:17:50 UTC
(In reply to comment #5)
> Created an attachment (id=25339) [details]

wrong issue, sorry.