Author: peterreilly
Date: Sun Sep 17 15:10:50 2006
New Revision: 447159

URL: http://svn.apache.org/viewvc?view=rev&rev=447159
Log:
Bugzilla 33604: classconstants filter broken

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/contributors.xml
    ant/core/trunk/docs/manual/CoreTypes/filterchain.html
    ant/core/trunk/src/main/org/apache/tools/ant/filters/ClassConstants.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?view=diff&rev=447159&r1=447158&r2=447159
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/WHATSNEW
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=447159&r1=447158&r2=447159
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sun Sep 17 15:10:50 2006
@@ -4,6 +4,9 @@
 Changes that could break older environments:
 -------------------------------------------
 
+* <classconstants> filter reader uses ISO-8879-1 encoding to read
+  the java class file. Bugzilla report 33604.
+
 Fixed bugs:
 -----------
 

Modified: ant/core/trunk/contributors.xml
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?view=diff&rev=447159&r1=447158&r2=447159
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Sun Sep 17 15:10:50 2006
@@ -840,6 +840,10 @@
     <last>Vaughn</last>
   </name>
   <name>
+    <first>Ronen</first>
+    <last>Mashal</last>
+  </name>
+  <name>
     <first>Russell</first>
     <last>Gold</last>
   </name>

Modified: ant/core/trunk/docs/manual/CoreTypes/filterchain.html
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTypes/filterchain.html?view=diff&rev=447159&r1=447158&r2=447159
==============================================================================
--- ant/core/trunk/docs/manual/CoreTypes/filterchain.html (original)
+++ ant/core/trunk/docs/manual/CoreTypes/filterchain.html Sun Sep 17 15:10:50 
2006
@@ -162,30 +162,50 @@
 
 <h3><a name="classconstants">ClassConstants</a></h3>
 <p>
-This filters basic constants defined in a Java Class,
-and outputs them in lines composed of the format <i>name</i>=<i>value</i>.
-See <a href="../install.html#librarydependencies">Library Dependencies</a>.
+  This filters basic constants defined in a Java Class,
+  and outputs them in lines composed of the format <i>name</i>=<i>value</i>.
+  This filter uses the <em>bcel</em> library to understand the Java Class file.
+  See <a href="../install.html#librarydependencies">Library Dependencies</a>.
 <p>
+  <p>
+    <em><b>Important:</b></em>
+    This filter is different from most of the other filters.
+    Most of the filters operate on a sequence of characters.
+    This filter operates on the sequence of bytes that makes up
+    a class. However the bytes arrive to the filter as a sequence
+    of characters. This means that one must be careful on the
+    choice of character encoding to use. Most encoding lose information
+    on conversion from an arbitary sequence of bytes to characters
+    and back again to bytes. In particular the usual default
+    character encodings (CP152 and UTF-8) do.
+    For this reason, <em>since Ant 1.7</em>, the character
+    encoding <b>ISO-8859-1</b> is used to convert from characters back to
+    bytes, so one <b>has</b> to use this encoding for reading the java
+    class file.
 <h4>Example:</h4>
 
 This loads the basic constants defined in a Java class as Ant properties.
+
 <blockquote><pre>
-&lt;loadproperties srcfile=&quot;foo.class&quot;&gt;
+&lt;loadproperties srcfile="foo.class" encoding="ISO-8859-1"&gt;
   &lt;filterchain&gt;
-    &lt;filterreader 
classname=&quot;org.apache.tools.ant.filters.ClassConstants&quot;/&gt;
+    &lt;classconstants/&gt;
   &lt;/filterchain&gt;
 &lt;/loadproperties&gt;
 </pre></blockquote>
 
-Convenience method:
-<blockquote><pre>
-&lt;loadproperties srcfile=&quot;foo.class&quot;&gt;
+This loads the constants from a Java class file as Ant properties,
+prepending the names with a prefix.
+
+    <blockquote><pre>
+&lt;loadproperties srcfile="build/classes/org/acme/bar.class"
+                encoding="ISO-8859-1"&gt;
   &lt;filterchain&gt;
     &lt;classconstants/&gt;
+    &lt;prefixlines prefix="ini."/&gt;
   &lt;/filterchain&gt;
 &lt;/loadproperties&gt;
 </pre></blockquote>
-
 <h3><a name="escapeunicode">EscapeUnicode</a></h3>
 <p>
 This filter converts its input by changing all non US-ASCII characters

Modified: 
ant/core/trunk/src/main/org/apache/tools/ant/filters/ClassConstants.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/filters/ClassConstants.java?view=diff&rev=447159&r1=447158&r2=447159
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/filters/ClassConstants.java 
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/filters/ClassConstants.java 
Sun Sep 17 15:10:50 2006
@@ -21,6 +21,7 @@
 import java.io.Reader;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import org.apache.tools.ant.BuildException;
 
 
 /**
@@ -103,7 +104,7 @@
             if (clazz == null) {
                 ch = -1;
             } else {
-                final byte[] bytes = clazz.getBytes();
+                final byte[] bytes = clazz.getBytes("ISO-8859-1");
                 try {
                     final Class javaClassHelper =
                         Class.forName(JAVA_CLASS_HELPER);
@@ -125,16 +126,21 @@
                             return read();
                         }
                     }
-                } catch (ClassNotFoundException cnfe) {
-                    throw new IOException(cnfe.getMessage());
-                } catch (NoSuchMethodException nsme) {
-                    throw new IOException(nsme.getMessage());
-                } catch (IllegalAccessException iae) {
-                    throw new IOException(iae.getMessage());
-                } catch (IllegalArgumentException iarge) {
-                    throw new IOException(iarge.getMessage());
-                } catch (InvocationTargetException ite) {
-                    throw new IOException(ite.getMessage());
+                } catch (NoClassDefFoundError ex) {
+                    throw ex;
+                } catch (RuntimeException ex) {
+                    throw ex;
+                } catch (InvocationTargetException ex) {
+                    Throwable t = ex.getTargetException();
+                    if (t instanceof NoClassDefFoundError) {
+                        throw (NoClassDefFoundError) t;
+                    }
+                    if (t instanceof RuntimeException) {
+                        throw (RuntimeException) t;
+                    }
+                    throw new BuildException(t);
+                } catch (Exception ex) {
+                    throw new BuildException(ex);
                 }
             }
         }



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

Reply via email to