meson icon indicating copy to clipboard operation
meson copied to clipboard

Java builds ignore `--werror`

Open bgilbert opened this issue 1 year ago • 2 comments

Describe the bug The --werror option does not cause Java builds to fail on warnings.

To Reproduce

$ cat > meson.build <<EOF
project('test', 'java')
add_project_arguments('-Xlint:all', language: 'java')
jar('result', 'Test.java')
EOF
$ cat > Test.java <<EOF
public class Test {
    public static void main(String args[]) {
        System.out.println(1 / 0);
    }
}
EOF
$ meson setup build --werror
The Meson build system
Version: 1.4.99
Source dir: /home/bgilbert/tmp/t
Build dir: /home/bgilbert/tmp/t/build
Build type: native build
Project name: test
Project version: undefined
Java compiler for the host machine: javac (unknown 22-ea)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Build targets in project: 1

test undefined

  User defined options
    werror: true

Found ninja-1.11.1 at /usr/bin/ninja
$ cd build; ninja
[1/2] Compiling Java object ../Test.java
../Test.java:3: warning: [divzero] division by zero
        System.out.println(1 / 0);
                               ^
1 warning
[2/2] Creating JAR result.jar
$ echo $?
0

Expected behavior The build fails.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? native
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) Fedora 39
  • what Python version are you using e.g. 3.8.0 3.12.2
  • what meson --version 1.4.99 (ef2b164f1f6b)
  • what ninja --version if it's a Ninja build 1.11.1

bgilbert avatar Apr 09 '24 13:04 bgilbert

Should be a pretty simple PR if you're up for it.

tristan957 avatar Apr 11 '24 05:04 tristan957

PR in https://github.com/mesonbuild/meson/pull/13074.

bgilbert avatar Apr 11 '24 20:04 bgilbert