Skip to content

ANTLR 4.12.0 may produce Java sources with illegal unicode escapes under Windows if a package name begins with 'u' #4128

@DanySK

Description

@DanySK

This is a regression, as 4.11.1 works correctly.

For files with a package starting in u, for instance it.unibo.xxx, when used under Windows, ANTLR 4.12.0 produces a header comment in the form:

// Generated from it\unibo\alchemist\model\internal\biochemistry\dsl\Biochemistrydsl.g4 by ANTLR 4.12.0

This is problematic, however, as the Java compiler reports it as error: illegal unicode escape

Here is a gradle scan showing the issue:
https://scans.gradle.com/s/uxdeejknwdmve/console-log?task=:alchemist-incarnation-biochemistry:compileJava

Quick reproduction can be achieved with the following:

git clone https://github.com/AlchemistSimulator/Alchemist.git
cd Alchemist
git checkout renovate/antlr4
./gradlew :alchemist-incarnation-biochemistry:compileJava

The fix should be reasonably easy; I'd suggest converting backslashes to slashes in the header (also, this would generate the same comment code for all the platforms).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions