[ 
https://issues.apache.org/jira/browse/BCEL-379?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory resolved BCEL-379.
----------------------------------
    Fix Version/s: 6.14.0
         Assignee: Gary D. Gregory
       Resolution: Fixed

[~aryanrg] Fixed in git master and snapshot builds, please verify and close.

> BCELifier emits invalid generated code for boolean ConstantValue fields
> -----------------------------------------------------------------------
>
>                 Key: BCEL-379
>                 URL: https://issues.apache.org/jira/browse/BCEL-379
>             Project: Commons BCEL
>          Issue Type: Bug
>            Reporter: Aryan Ganjoo
>            Assignee: Gary D. Gregory
>            Priority: Major
>             Fix For: 6.14.0
>
>
> A class with `public static final boolean ON = true;` has a 
> CONSTANT_Integer-backed ConstantValue attribute. BCELifier.visitField 
> currently prints that integer in its generated creator, producing 
> `field.setInitValue(1);`. FieldGen then selects its int overload and rejects 
> the boolean field with `ClassGenException: Types are not compatible: boolean 
> vs. int` when the creator runs. The same issue applies to a false 
> ConstantValue (0).
> Reproduction: compile a class containing a static final boolean, run 
> `org.apache.bcel.util.BCELifier` on it, compile the emitted creator, then run 
> that creator. Expected: a rebuilt class with the boolean field. Actual: the 
> creator throws the ClassGenException above. This is distinct from BCEL-221 
> (invokedynamic constant-pool index) and BCEL-135 (float/long method 
> constants).
> The fix renders boolean literals for boolean fields. The added fixture covers 
> true and false and runs through the existing BCELifier compile/run/javap 
> round-trip test. The default `mvn` build and `mvn -q verify` passed locally. 
> Pull request: https://github.com/apache/commons-bcel/pull/536
> AI assistance used for code and test drafting.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to