On Jan 24, 2005, at 11:05 AM, michael sorens wrote:
(1) Well I tried adding bcel.jar to my ant/lib directory but it made no difference.
What did make a difference was my choice of .class file to load. Instead of my Diagnostic.class
I tried a simpler Version.class and then I received no error, even *without* bcel.jar. So this seems like a data-dependent bug...

Did you make your VERSION be "public static final"? I just tried it (had to download and install BCEL into ANT_HOME/lib myself) with this class:


public class Test {
  public static final String VERSION = "version";
}

I also tried it with an int:

  public static final int VERSION = 123;

with this build file snippet:

   <loadproperties srcfile="build/Test.class">
       <filterchain>
         <classconstants/>
       </filterchain>
    </loadproperties>
    <echo>${VERSION}</echo>

(2) As I could successfully execute with my Version.class, how do I then *access* the properties?
I have a constant named VERSION. I tried <echo> with "${VERSION}" and with "${com.cleancode.data.Version.VERSION}" but neither had a value. What are the rules for the name of a property from a class file?

the property name is the constant name, no package prefix is added. Though a slick trick is to use a <prefixlines prefix="constants."/> after <classconstants>.


My guess is your property is not public static final.

        Erik


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to