Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"javac returned non-zero exit code", but no errors #520

Closed
eed3si9n opened this issue Mar 28, 2018 · 10 comments
Closed

"javac returned non-zero exit code", but no errors #520

eed3si9n opened this issue Mar 28, 2018 · 10 comments

Comments

@eed3si9n
Copy link
Member

eed3si9n commented Mar 28, 2018

There's been a report that the user would see

[error] (xxx / Compile / compileIncremental) javac returned non-zero exit code
[error] Total time: 74 s, completed Mar 22, 2018 11:23:58 AM

but the actual error messages from Java does not get printed out.
I think I've seen some of these myself as well.

Ref sbt/sbt#2256
Ref sbt/sbt#3665
Ref #376

@eed3si9n eed3si9n added the bug label Mar 28, 2018
@jvican
Copy link
Member

jvican commented Mar 28, 2018

That would be confirmed by #376, which I closed because I couldn't reproduce.

@eed3si9n eed3si9n changed the title "javac returned non-zero exit code", but not errors "javac returned non-zero exit code", but no errors Mar 29, 2018
eed3si9n added a commit to eed3si9n/sbt that referenced this issue Apr 5, 2018
This is an attempt to fix sbt/zinc#520
@eed3si9n eed3si9n self-assigned this Apr 5, 2018
@retronym
Copy link
Member

retronym commented Apr 8, 2018

To diagnose this problem further, I suggest setting javaHome := Some(file("<path to jdk>")), which will run javac in forked mode. That might workaround some buggy error reporting code in the non-forked mode.

@eed3si9n
Copy link
Member Author

I sat down with the customer today with his laptop, and was able to reproduce this. On the environment, JAVA_HOME was set, which was setting javaHome to Some(...). When we unset JAVA_HOME, we were then able to see:

cannot find symbol
  symbol: method blabla
  location: variable runtime of type xxx.abc

In other words, the bug is likely in the error handling of forked mode.

eed3si9n added a commit to eed3si9n/zinc that referenced this issue Jul 5, 2018
This is an improvement over the status quo of forked Javac error parsing,
but likely not a complete fix.

"Normal" Java error messages look like:

```
/path/a.java:100:1: error message
        if (x.isBar) {
              ^
  symbol: xxx
  location: xxx
```

However, under certain circumstances javac reports compiler errors are reported as:

```
/path/a.java:100:1: error message
symbol: xxx
location: xxx
if (x.isBar) {
```

Current parsing assumes existence of `^` as well as indentation before "symbol" etc.

Ultimately a better way of handling forking probably is to define our own small commandline app, like forked tests are done.
eed3si9n added a commit to eed3si9n/zinc that referenced this issue Jul 5, 2018
This is an improvement over the status quo of forked Javac error parsing,
but likely not a complete fix.

"Normal" Java error messages look like:

```
/path/a.java:100:1: error message
        if (x.isBar) {
              ^
  symbol: xxx
  location: xxx
```

However, under certain circumstances javac reports compiler errors are reported as:

```
/path/a.java:100:1: error message
symbol: xxx
location: xxx
if (x.isBar) {
```

Current parsing assumes existence of `^` as well as indentation before "symbol" etc.

Ultimately a better way of handling forking probably is to define our own small commandline app, like forked tests are done.
@jvican
Copy link
Member

jvican commented Jul 11, 2018

I finally found the root of the error here. This happens whenever JavaThenScala is used. The reason why it happens is because Zinc doesn't internally do printSummary for Java, it only does it for Scala in the CompilerInterface, and therefore the messages from Javac are received but unreported.

@olafurpg
Copy link
Member

olafurpg commented Aug 6, 2018

I'm hitting on this error in building a pure Java module and lack of error messages makes it near impossible to be productive while writing Java code. A workaround is to explicitly declare javaHome.in(Compile) as we do in the Scalameta build.sbt

javaHome.in(Compile) := {
  Some(file(sys.props("java.home")).getParentFile)
}

@jvican
Copy link
Member

jvican commented Sep 15, 2018

Cross-linking #415, which contains an example reproducing this error. I'm closing that ticket and keeping this one open as it's richer in details.

@wpc009
Copy link

wpc009 commented Oct 29, 2018

Any workaround for this issue?

@olafurpg
Copy link
Member

@wpc009 The workaround in #520 (comment) works for me under sbt version 1.1.6 but not the latest sbt 1.2.x.

@raboof
Copy link
Contributor

raboof commented Dec 14, 2018

Is this fixed by #448 or is there more work to do?

@eed3si9n
Copy link
Member Author

Until we find a new failure mode other than the one fixed in #448 etc, I am going to close this.

agluszak added a commit to build-server-protocol/build-server-protocol that referenced this issue Apr 9, 2023
- Remove generated java sources from the repo
- Move every subproject to scala 2.13
- Remove inferJavaHome hack (the issue has been fixed apparently: sbt/zinc#520)
- Add myself as a developer
- Change license link to https
agluszak added a commit to build-server-protocol/build-server-protocol that referenced this issue Apr 12, 2023
- Move every subproject to scala 2.13
- Remove inferJavaHome hack (the issue has been fixed apparently: sbt/zinc#520)
- Add myself as a developer
- Change license link to https
agluszak added a commit to build-server-protocol/build-server-protocol that referenced this issue Apr 12, 2023
- Move every subproject to scala 2.13
- Remove inferJavaHome hack (the issue has been fixed apparently: sbt/zinc#520)
- Change developers list
- Change license link to https
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants