Skip to content

Add regression test for static field from missing class#8762

Open
tautschnig wants to merge 1 commit intodiffblue:developfrom
tautschnig:fix-851-static
Open

Add regression test for static field from missing class#8762
tautschnig wants to merge 1 commit intodiffblue:developfrom
tautschnig:fix-851-static

Conversation

@tautschnig
Copy link
Collaborator

@tautschnig tautschnig commented Nov 30, 2025

Add a regression test verifying that static fields accessed via getstatic bytecode from a missing class are properly marked with is_static_lifetime and nondet-initialized. The underlying issue was already fixed by the create_stub_global_symbol function (commit e163ab6, Feb 2018), which correctly sets is_static_lifetime=true for stub globals. This test guards against regressions.

Fixes: #851

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@tautschnig tautschnig self-assigned this Feb 24, 2026
Add a regression test verifying that static fields accessed via getstatic
bytecode from a missing class are properly marked with is_static_lifetime
and nondet-initialized. The underlying issue was already fixed by the
create_stub_global_symbol function (commit e163ab6, Feb 2018), which
correctly sets is_static_lifetime=true for stub globals. This test guards
against regressions.

Fixes: diffblue#851

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig tautschnig changed the title Java bytecode front-end: fix static field is_static_lifetime flag Add regression test for static field from missing class Mar 18, 2026
@tautschnig tautschnig marked this pull request as ready for review March 18, 2026 22:07
Copilot AI review requested due to automatic review settings March 18, 2026 22:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new JBMC regression test intended to guard against regressions where a getstatic access to a static field of a missing class fails to create a proper stub global (with is_static_lifetime set) and fails to nondet-initialize it.

Changes:

  • Add a new regression directory static_field_missing_class/ with a minimal Java program that reads a static field from a missing class.
  • Add a test.desc expecting an assertion failure and a warning.
  • Check in the precompiled a.class artifact for the regression.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
jbmc/regression/jbmc/static_field_missing_class/test.desc Adds a regression harness entry to run JBMC and match expected output.
jbmc/regression/jbmc/static_field_missing_class/a.java Adds the Java source corresponding to the test scenario (missing class static field access).
jbmc/regression/jbmc/static_field_missing_class/a.class Adds the compiled bytecode used by the regression test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3 to +7
--function a.fun
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
assertion at file a.java line 3 .*: FAILURE
public static void fun() {
assert b.x > 0;
}
}
@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.41%. Comparing base (85c204f) to head (eabdff5).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8762   +/-   ##
========================================
  Coverage    80.41%   80.41%           
========================================
  Files         1703     1703           
  Lines       188398   188398           
  Branches        73       73           
========================================
+ Hits        151498   151499    +1     
+ Misses       36900    36899    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail to mark variable as static lifetime

2 participants