Skip to content

[MCOMPILER-485] Incorrect internal string format in generated package-info.class files on Windows #235

Closed
@sos-jira-migration-bot

Description

@sos-jira-migration-bot

Daniel Widdis opened MCOMPILER-485 and commented

In 3.10.0, a new feature to generate package-info classes was added in [MCOMPILER-205]

Unfortunately, the binary class file is incorrectly generated using Java's file toString() which uses a platform dependent file separator character: on Windows, these Strings contain a backslash.  See this line which passes the platform-dependent file name (minus the root path and .java extension) to the ClassWriter.

The Java class file specification (4.2.1) specifies the internal format: "In this internal form, the ASCII periods (.) that normally separate the identifiers which make up the binary name are replaced by ASCII forward slashes (/)."

This invalid class file format causes problems in downstream plugins, e.g.,

  • The bnd-maven-plugin fails with an error: Classes found in the wrong directory: {oshi/jna/platform/unix/package-info.class=oshi\jna\platform\unix\package-info ... (and hundreds more) ... }
  • The JDK's classFileParser will throw java.lang.NoClassDefFoundError: com\puppycrawl\tools\checkstyle\ant\package-info (wrong name: com/puppycrawl/tools/checkstyle/ant/package-info

Steps to reproduce:

  1. Perform a build on any Windows machine using maven-compiler-plugin 3.10.0
  2. Inspect any of the generated package-info.class files in target/classes using a text editor

Expected behavior:

Internal strings representing package names use forward slashes

Observed behavior:

Internal strings representing package names use backward slashes

 


Affects: 3.10.0

Issue Links:

  • MCOMPILER-205 incremental compilation broken for package-info classes
    ("is caused by")

Remote Links:

3 votes, 8 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions