Skip to content

fix(#4730): better message for missing 'package-info.class' in PhPackage.java#4784

Merged
yegor256 merged 2 commits into
objectionary:masterfrom
volodya-lombrozo:4730-ph-package-error
Dec 31, 2025
Merged

fix(#4730): better message for missing 'package-info.class' in PhPackage.java#4784
yegor256 merged 2 commits into
objectionary:masterfrom
volodya-lombrozo:4730-ph-package-error

Conversation

@volodya-lombrozo

@volodya-lombrozo volodya-lombrozo commented Dec 30, 2025

Copy link
Copy Markdown
Member

This PR improves the verification message of a missing package-info.class in PhPackage.java.

Fixes #4730

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error reporting for missing package-info classes with explicit messages indicating exactly what could not be resolved, improving debuggability.
  • Tests

    • Added test coverage to validate error handling and messaging when package-info resolution fails.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 30, 2025 11:06
@github-actions github-actions Bot added the core label Dec 30, 2025
@volodya-lombrozo volodya-lombrozo marked this pull request as draft December 30, 2025 11:06
@coderabbitai

coderabbitai Bot commented Dec 30, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

The changes improve package-info class resolution error handling in the PhPackage runtime. A dedicated package-info class path lookup is introduced, providing explicit error messages when the package-info class cannot be found, with fallback to the target class. Corresponding test coverage and integration test assertions are updated to validate the new behavior.

Changes

Cohort / File(s) Summary
Package-info Resolution Logic
eo-runtime/src/main/java/org/eolang/PhPackage.java
Introduces explicit pinfo path ("<target>.package-info") lookup via Class.forName(). Raises ExFailure with detailed error message including exact missing class and package-info path. Maintains fallback to target class loading if package-info resolution fails.
Test Coverage
eo-runtime/src/test/java/org/eolang/PhPackageTest.java, eo-integration-tests/src/test/java/integration/JarIT.java
Added new test method throwsExceptionsIfCantFindPackageInfo() to validate error handling when package-info is missing. Updated JarIT error assertion to expect new explicit package-info error message format.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

core

Poem

🐰 A package-info hunt with focus true,
Error messages clear as morning dew,
Tests now guard the missing class,
Resolving puzzles, on we pass!
Package paths explicit shine,
Fallback flows work just fine! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: improving the error message when 'package-info.class' is missing in PhPackage.java, which aligns with the changeset modifications.
Linked Issues check ✅ Passed The PR addresses issue #4730 by improving the error message for missing package-info.class and implements the required changes to PhPackage.java around lines 125-134.
Out of Scope Changes check ✅ Passed All changes are directly related to improving the package-info error messaging in PhPackage.java and its corresponding tests, with no unrelated modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 99fca89 and 49084f5.

📒 Files selected for processing (3)
  • eo-integration-tests/src/test/java/integration/JarIT.java
  • eo-runtime/src/main/java/org/eolang/PhPackage.java
  • eo-runtime/src/test/java/org/eolang/PhPackageTest.java
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-12T15:24:05.011Z
Learnt from: h1alexbel
Repo: objectionary/eo PR: 4431
File: eo-parser/src/main/resources/XMIR.xsd:80-81
Timestamp: 2025-08-12T15:24:05.011Z
Learning: In the EO parser architecture, Φ̇ is an alias for Φ.org.eolang that gets expanded during XMIR decoration by expand-qqs.xsl. The XSD schema for FQN patterns should only validate canonical forms (Φ and ξ as roots) since alias expansion happens before XSD validation.

Applied to files:

  • eo-runtime/src/main/java/org/eolang/PhPackage.java
📚 Learning: 2025-10-17T14:21:45.092Z
Learnt from: h1alexbel
Repo: objectionary/eo PR: 4637
File: eo-parser/src/main/resources/org/eolang/parser/parse/resolve-compacts.xsl:27-31
Timestamp: 2025-10-17T14:21:45.092Z
Learning: In the EO language aliasing system, only concrete objects (complete paths to objects, e.g., `org.eolang.io.stdout`) can be aliased, not intermediate packages or partial paths (e.g., `org.eolang.io`). This means aliases always point to final objects, not package prefixes.

Applied to files:

  • eo-integration-tests/src/test/java/integration/JarIT.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: mvn (windows-2022, 23)
  • GitHub Check: integration
  • GitHub Check: qulice
  • GitHub Check: mvn (macos-15, 23)
  • GitHub Check: mvn (ubuntu-24.04, 23)
  • GitHub Check: mvn (ubuntu-24.04, 17)
  • GitHub Check: pr-size
  • GitHub Check: ort
  • GitHub Check: snippets
  • GitHub Check: benchmark
  • GitHub Check: trufflehog
🔇 Additional comments (4)
eo-integration-tests/src/test/java/integration/JarIT.java (1)

185-186: LGTM! Test assertion correctly updated.

The error message assertion now validates the improved error format that includes both the missing class and the package-info class path, aligning with the production code changes in PhPackage.java.

eo-runtime/src/main/java/org/eolang/PhPackage.java (2)

129-132: Explicit package-info check improves error clarity.

The dedicated pinfo variable and explicit Class.forName(pinfo) call make the package-info existence check clear and enable the improved error messaging in the fallback path. The logic correctly attempts package-info loading first, then falls back to the target class.


142-143: Improved error message enhances debuggability.

The error message now explicitly identifies both the target class and the package-info class that could resolve the missing object, making it much easier for users to diagnose class loading issues.

eo-runtime/src/test/java/org/eolang/PhPackageTest.java (1)

113-126: Good negative test coverage for missing package-info.

The test correctly validates that attempting to load a non-existent package-info results in an ExFailure with the expected error message format, ensuring the improved error messaging works as intended.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@volodya-lombrozo

Copy link
Copy Markdown
Member Author

Blocked by #4782

@github-actions

github-actions Bot commented Dec 30, 2025

Copy link
Copy Markdown
Contributor

🚀 Performance Analysis

All benchmarks are within the acceptable range. No critical degradation detected (threshold is 100%). Please refer to the detailed report for more information.

Click to see the detailed report
Test Base Score PR Score Change % Change Unit Mode
benchmarks.XmirBench.xmirToEO 185.297 194.700 9.403 5.07% ms/op Average Time

⚠️ Performance loss: benchmarks.XmirBench.xmirToEO is slower by 9.403 ms/op (5.07%)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the error message when a package-info.class file is missing during object lookup in the EO runtime. The error message now explicitly mentions both the missing class and the missing package-info class, making it clearer what went wrong. Additionally, the PR includes a refactoring cleanup that removes a duplicate test utility class.

  • Enhanced error message in PhPackage.java to explicitly mention the missing package-info class
  • Added test coverage to verify the improved error message
  • Refactored test utilities to use standard matchers instead of custom duplicate classes

Reviewed changes

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

Show a summary per file
File Description
eo-runtime/src/main/java/org/eolang/PhPackage.java Improved error message format to explicitly mention missing package-info class and removed completed TODO
eo-runtime/src/test/java/org/eolang/PhPackageTest.java Added test to verify the improved error message for missing package-info class
eo-integration-tests/src/test/java/org/eolang/maven/MjAssembleIT.java Renamed method for clarity and replaced custom matcher with standard FileMatchers
eo-integration-tests/src/test/java/org/eolang/maven/ContainsFiles.java Removed duplicate utility class that is no longer needed
.github/workflows/simian.yml Removed exclusion for deleted ContainsFiles.java

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

Comment thread eo-runtime/src/test/java/org/eolang/PhPackageTest.java Outdated
private Phi loadPhi(final String fqn) {
final String target = new JavaPath(fqn).toString();
final String pinfo = String.format("%s.package-info", target);
Phi loaded;

Copilot AI Dec 30, 2025

Copy link

Choose a reason for hiding this comment

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

According to the coding guidelines, blank lines should not be used inside method bodies as they reduce code readability. Remove this blank line.

Copilot generated this review using guidance from organization custom instructions.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
eo-runtime/src/test/java/org/eolang/PhPackageTest.java (1)

113-126: Good test coverage for missing package-info!

The test correctly verifies that the error message now explicitly mentions both the missing class and package-info class, which improves debuggability.

Optional: Fix method name consistency

The method name uses plural "Exceptions" but only one exception is thrown. For consistency with line 105 (throwsExceptionIfCantInstantiateObject), consider:

-    void throwsExceptionsIfCantFindPackageInfo() {
+    void throwsExceptionIfCantFindPackageInfo() {
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e82e0e4 and 99fca89.

📒 Files selected for processing (5)
  • .github/workflows/simian.yml
  • eo-integration-tests/src/test/java/org/eolang/maven/ContainsFiles.java
  • eo-integration-tests/src/test/java/org/eolang/maven/MjAssembleIT.java
  • eo-runtime/src/main/java/org/eolang/PhPackage.java
  • eo-runtime/src/test/java/org/eolang/PhPackageTest.java
💤 Files with no reviewable changes (1)
  • eo-integration-tests/src/test/java/org/eolang/maven/ContainsFiles.java
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-12T15:24:05.011Z
Learnt from: h1alexbel
Repo: objectionary/eo PR: 4431
File: eo-parser/src/main/resources/XMIR.xsd:80-81
Timestamp: 2025-08-12T15:24:05.011Z
Learning: In the EO parser architecture, Φ̇ is an alias for Φ.org.eolang that gets expanded during XMIR decoration by expand-qqs.xsl. The XSD schema for FQN patterns should only validate canonical forms (Φ and ξ as roots) since alias expansion happens before XSD validation.

Applied to files:

  • eo-runtime/src/main/java/org/eolang/PhPackage.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: CodeQL analysis (java)
  • GitHub Check: Agent
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: qulice
  • GitHub Check: benchmark
  • GitHub Check: mvn (macos-15, 23)
  • GitHub Check: integration
  • GitHub Check: ort
  • GitHub Check: snippets
  • GitHub Check: mvn (ubuntu-24.04, 23)
  • GitHub Check: mvn (windows-2022, 23)
  • GitHub Check: trufflehog
  • GitHub Check: mvn (ubuntu-24.04, 17)
  • GitHub Check: pr-size
🔇 Additional comments (5)
.github/workflows/simian.yml (1)

24-24: LGTM!

The exclusion is correctly removed since ContainsFiles.java no longer exists after being deleted in this PR.

eo-integration-tests/src/test/java/org/eolang/maven/MjAssembleIT.java (3)

18-18: LGTM!

The addition of FileMatchers import aligns with replacing the custom ContainsFiles matcher with standard Hamcrest matchers.


42-42: LGTM on the method rename!

The rename from appendItself to registerAssemble is clearer and better describes what the method does—registering and assembling the plugin.

Also applies to: 83-83, 107-110


87-89: LGTM on using FileMatchers!

Using FileMatchers.anExistingFile() with a concrete path is more idiomatic and maintainable than a custom matcher.

eo-runtime/src/main/java/org/eolang/PhPackage.java (1)

129-143: Excellent improvement to error messaging!

The change successfully addresses issue #4730 by explicitly checking for package-info.class existence and providing a clear error message when neither the class nor package-info is found. The error message now tells users exactly what's missing, which significantly improves debuggability.

The logic correctly:

  1. Constructs the package-info path
  2. Attempts to load it first to determine if it's a package
  3. Falls back to loading the target class if package-info doesn't exist
  4. Reports both expected paths in the error message when both are missing

@github-actions github-actions Bot removed the core label Dec 30, 2025
@volodya-lombrozo volodya-lombrozo marked this pull request as ready for review December 30, 2025 12:52
@volodya-lombrozo

Copy link
Copy Markdown
Member Author

@yegor256 could you have a look, please?

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@yegor256 yegor256 merged commit 54e5e91 into objectionary:master Dec 31, 2025
24 of 26 checks passed
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.

'package-info.class' Verification Fails in PhPackage.java

3 participants