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/17 21:43:00 UTC
[jira] [Updated] (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 updated BCEL-379:
------------------------------
Description:
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.
was:
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).
A local 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 focused `BCELifierTest` suite passed locally (51 tests, 1 skipped); full validation and independent final review are in progress. No patch is public yet.
AI assistance used for code and test drafting.
> 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
> Priority: Major
>
> 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)