Fix #341: Add model classes for java.util.logging#584
Open
HritikRaj2 wants to merge 2 commits into
Open
Conversation
cyrille-artho
requested changes
Dec 19, 2025
Member
cyrille-artho
left a comment
There was a problem hiding this comment.
Looks good!
Please add the copyright header (the first five lines of comments that is present in all files and also about half of the new files you have created) to the remaining files.
Contributor
Author
|
@cyrille-artho |
Contributor
Author
|
@cyrille-artho |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
JPF crashes when code calls Logger.getLogger() because the real JDK implementation relies on native methods (e.g., jdk.internal.misc.VM.initializeFromArchive), unsupported Thread constructors, and complex security/filesystem APIs that are not supported in the Model Java Interface (MJI).
Solution
Implemented a set of model classes for the java.util.logging package. These models provide a simplified, pure-Java implementation compatible with JPF that supports basic logging operations, handler management, and stream output without relying on native JDK internals.
Changes
src/classes/modules/java.logging/java/util/logging/Logger.java: Updated to support adding/removing handlers and publishing log records.src/classes/modules/java.logging/java/util/logging/LogManager.java: Minimal implementation to manage logger instances.src/classes/modules/java.logging/java/util/logging/Level.java: Model class defining standard log levels.src/classes/modules/java.logging/java/util/logging/Handler.java: Abstract base class for log handlers.src/classes/modules/java.logging/java/util/logging/StreamHandler.java: Implements log publishing to an output stream (throws IOException correctly on flush).src/classes/modules/java.logging/java/util/logging/LogRecord.java: Encapsulates log data.src/classes/modules/java.logging/java/util/logging/Formatter.java: Abstract base for log formatting.src/tests/gov/nasa/jpf/test/java/util/LoggerTest.java: New test case verifying logger caching and output capturing via ByteArrayOutputStream (assertions only, no console printing).Testing
All existing tests pass + new test confirms
Logger.getLogger()works without crashes.