Constructor in ant task
Java class file shrinker, optimizer, obfuscator, and preverifier
Brought to you by:
guardsquare
Version : 3.0.7
JDK : 1.3
OS : M$ Windows XP
When I try to use the ant task with an XML
configuration with constructor, like:
<keepclasseswithmembers name="com.zz.**.*X">
<constructor access="public" parameters="com..zz.MyClass"/>
</keepclasseswithmembers>
The build process fails and an error:
BUILD FAILED: file:build.xml:46: Type and parameters
attributes must always be present in combination in
method specification
If the above line is removed, the problem does not
occur anymore. I read the documentation, but I can
figure out why this error happens.
Thanks for your work and help.
Logged In: YES
user_id=555208
The error message means that you must specify the "type"
attribute if you specify the "parameters" attribute. Just
like in the ProGuard configuration outside of Ant, one can't
go without the other. So you may want to add something like
type="void", or type="**".
Logged In: YES
user_id=534415
Adding a "type" doesn't work so well either. Adding this:
<constructor
type="**"
param="java.rmi.activation.ActivationID,java.rmi.MarshalledObject"/>
spits out:
/home/wms/apps/igoweb/build.xml:741: Type attribute not
allowed in constructor specification [**]
Setting type to "void" gives a similar output. So it seems
the only workaround right now is to use the non-XML
configuration.
Logged In: YES
user_id=555208
You're right; I hadn't noticed you were referring to a
constructor, not just a method. This is a genuine bug. It
should be fixed by changing the body of the if-statement at
line 72 in proguard/ant/ClassMemberSpecificationElement.java to:
if (isConstructor)
{
if (type != null)
{
throw new BuildException("Type attribute
not allowed in constructor specification ["+type+"]");
}
if (parameters != null)
{
type = ClassConstants.EXTERNAL_TYPE_VOID;
}
name = ClassConstants.INTERNAL_METHOD_NAME_INIT;
}
Please let us know if you get the chance to try it out. This
fix will be applied in the next version.