You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Aryan Ganjoo (Jira)" <ji...@apache.org> on 2026/10/18 12:31:00 UTC
[jira] [Closed] (BCEL-379) BCELifier emits invalid generated code for boolean ConstantValue fields
[ https://issues.apache.org/jira/browse/BCEL-379?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Aryan Ganjoo closed BCEL-379.
-----------------------------
Thanks, Gary. I verified the fix in master at commit 7fc6cd4 by running the focused BCELifierTest and FieldGenTest tests and `mvn -q verify` locally. Both commands passed. Closing the issue as verified.
> 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)