How to build dagger itself - dagger

The dagger project uses bazel.build system to build. I have installed bazel on Fedora, it runs and builds the project but apparently dagger has Java 1.8 code, and bazel targets java 7.
There is a build_def.bzl file and java target version is defined like so:
SOURCE_7_TARGET_7 = ["-source 1.7 -target 1.7"]
changing it to
SOURCE_7_TARGET_7 = ["-source 1.8 -target 1.8"]
does not help. Both master and rc11 branches fail to build because of the same error (java compiler complains about target version 1.7 not supporting lambda and method reference). There is no guide for building dagger on the wiki or project page and I'm unfamiliar with bazel. I wonder if something like retrolambda must be added to the build runtime path but it doesn't seem easy with bazel.
Sample output:
$> bazel build :all
INFO: Found 8 targets...
ERROR: /home/user/dagger/java/dagger/internal/codegen/BUILD:44:1: Building java/dagger/internal/codegen/libcodegen.jar (116 source files) failed: java failed: error executing command external/local_jdk/bin/java -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac-9-dev-r4023-2.jar -XX:+TieredCompilation '-XX:TieredStopAtLevel=1' -jar ... (remaining 2 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
java/dagger/internal/codegen/AbstractComponentWriter.java:612: error: method references are not supported in -source 1.7
(use -source 8 or higher to enable method references)
java/dagger/internal/codegen/AnnotationExpression.java:80: error: lambda expressions are not supported in -source 1.7
(use -source 8 or higher to enable lambda expressions)
java/dagger/internal/codegen/AnnotationSpecs.java:41: error: method references are not supported in -source 1.7
(use -source 8 or higher to enable method references)
# Rest of output removed for brevity, the error above repeats for many more files.

I had wrong version of bazel installed. Building is as simple as running:
bazel build :all
I already had Oracle JDK 8 installed on my machine (Fedora) and downloaded this release of bazel (bazel-0.5.0-without-jdk-installer-linux-x86_64.sh).

Related

warning: [options] bootstrap class path not set in conjunction with -source 8

My JDK8 NetBeans project has the following warning. warning: [options] bootstrap class path not set in conjunction with -source 8
However, my code is building successfully! Can someone help with why this issue is happening?
also note Ant javac task now supports this option.
https://ant.apache.org/manual/Tasks/javac.html
"release Specify the value for the --release switch.
When set and running on JDK 9+ the source and target attributes as well as the bootclasspath will be ignored. Since Ant 1.9.8.
Required? No, ignored when running on JDK 8 or earlier"
For example, can replace source="1.8" and target="1.8" entries with a single release="8" entry. Note that release attribute has different values (no prefix "1." used).
Note also that this will fail if Ant 1.9 (or better) isn't available.
This can't be used in IDE-provided build files in the nbproject subdirectory, where build files have an explicit warning not to be edited.
Check that JAVA_HOME isn't set to a newer version than what you set in your NetBeans project. For my case, I had an Ant project using "1.8", but my JAVA_HOME was pointing to Java 11.

How to configure buckminster to not use default JDK to compile during build?

I'm creating a build job on jenkins, the main part of it is a buckminster launch:
The job requires Java 1.8 and it's integrated JavaFX. The servers JAVA_HOME points to a Java 1.7 and all other jobs use that JDK.
So I configured a 1.8 JDK in the Jenkins system configuration and added it to the specific job:
Now when I run the job I get the following log (anonymised):
$ C:/Progra~1/Java/jdk1.8.0_40\bin\java.exe -Dbuckminster.output.root=PATH_TO_OUTPUT\buckminster.output -Dbuckminster.temp.root=PATH_TO_TEMP\buckminster.temp -Dworkspace=PATH_TO_WORKSPACE -Dqualifier=${QUALIFIER} -Xmx1024m -XX:MaxPermSize=128m -jar PATH_TO_BUCKMINSTER\buckminster4.4.0\buckminster\plugins\org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar -application org.eclipse.buckminster.cmdline.headless -data PATH_TO_WORKSPACE --loglevel info -S PATH_TO_COMMANDS\commands.txt
INFO: setpref 'targetPlatformPath=PATH_TO_TARGETPLATFORM/targetPlatform'
INFO: import 'PATH_TO_CQUERY/site.cquery'
INFO: Import complete.
INFO: build
Error: file PATH_TO_CLASS\TargetController.java, line 11: The import javafx cannot be resolved
... lot more of there errors
Warning: file PATH_TO_MANIFEST\META-INF\MANIFEST.MF, line 98: The JRE container on the classpath is not a perfect match to the 'JavaSE-1.8' execution environment
So this indicates that the "build" is not using the configured JDK 1.8 eventhough it is beeing started with "C:/Progra~1/Java/jdk1.8.0_40\bin\java.exe".
The question is how do I configure buckminster to use my 1.8 JDK?
can you try the answer i specified:
How to trigger Jenkins builds remotely and to pass parameters
I mean even JDK can be parameterised, let me know.

bootstrap class path not set in conjunction with -source 1.6

I am upgrading my application from java 1.6 to 1.7. When I try to build using Maven 3.2.1, my build fails with below error msg:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project my-app5: Compilation failure: Compilation failure:
[ERROR] could not parse error message: warning: [options] bootstrap class path not set in conjunction with -source 1.6
I am using java 1.7 hotspot and previously I was using 1.6 jrockit. My application is multi module and few modules compile and build as usual, this module failed.
I have set java home properly and mvn --version shows below output:
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T23:07:52+05:30)
Maven home: C:\Users\me\Maven3\apache-maven-3.2.1-bin\apache-maven-3.2.1\bin\..
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: C:\Program Files\jdk17051\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Am I missing anything?
I solved it using below configuration in my compiler plugin:
<fork>true</fork>
<executable>${JAVA_HOME}/bin/javac</executable>
<compilerVersion>1.7</compilerVersion>
<source>1.7</source>
<target>1.7</target>
This will use the JDK which you have defined in your JAVA_HOME environment property.
Quote from this post:
Java 5.0 and 6 used to have poor support for compiling classes to
target older versions of Java. It always supported the previous
version, but often no more. Even if you could compile for previous
version, you had to be careful not to use functionality which did
exist in the previous versions.
You should either include -Xbootclasspath when using javac:
javac -Xbootclasspath:/path/to/jdk6/rt.jar -target 1.6 -source 1.6 Main.java
or compile using -target 1.7 (or higher of course):
javac -target 1.7 -source 1.7 Main.java
or use javac of jdk 6:
/path/to/jdk6/bin/javac Main.java

UnsupportedClassVersionError deploying EJB "HelloWord" in Glasshfish 3

I try to deploy a simple "Hello Word" in my local server GlasshFish 3, but at the deploy the console print this message
[#|2013-01-15T15:00:02.458+0100|SEVERE|glassfish3.1.2|
javax.enterprise.system.tools.admin.org.Exception while deploying the app
[HelloWorldEJB] :UnsupportedClassVersionError: Class ejb_other.PlaceAuctionItemBean
as unsupported major or minor version numbers, which are greater than those found
in the Java Runtime Environment version 1.6.0_27|#]
My JAVA_HOME has java version 1.6.0_27 (it refers to _C:\Program Files\Java\jdk1.6.0_27_), my Eclipse (indigo) project refers to java 1.6.0_27.
I think (i don't know how to verify) that GlasshFish refers to JAVA_HOME.
In my PC (Windows 7) I found 2 directory having java.exe:
C:\Windows\SysWOW64>java -version -->>java version "1.6.0_29"
C:\Windows\System32>java -version -->>java version "1.6.0_27"
I found more discussions about this exception (f.e. this or this ), but I need of something more specific for Eclipse/Glasshfish, because I can't to solve. I see that the JVM is the same for compilation and execution.
Post Scriptim
I add the screenshot about the places where I declare JVM: it's always 1.6.
one:
two:
three:
Where can I see that I compile with java 7 or it runs with another JVM?
ejb_other.PlaceAuctionItemBean was obviously compiled for Java 7 which won't work if you run it in a Java 6 JVM.
Found solution
There's another place where setting the compiler's options:
how do I get eclipse to use a different compiler version for Java?

Why won't Eclipse compile my code in java 1.5?

I have installed Eclipse 3.5.2 and the JDK for Java 6.
Here's my installed JREs in Eclipse
alt text http://img806.imageshack.us/img806/3345/eclipsejres.jpg
I am trying to compile with an ant build file, part of which looks like this and specifies java 1.5:
<target name="compile" depends="build-common, init" description="Compile files. ">
<javac srcdir="${src_dir}" destdir="${build_dir}" debug="true" target="1.5" source="1.5">
<classpath path="${tomcat_home}/lib/servlet-api.jar;${tomcat_home}/lib/log4j-1.2.15.jar;/usr/local/lib/portlet-api-1.0.jar;." />
</javac>
</target>
But when I try to compile, the console window displays the following error:
compile:
[javac] Compiling 1 source file to H:\jephperro\portlets\build
[javac] javac: invalid target release: 1.5
[javac] Usage: javac <options> <source files>
[javac] where possible options include:
[javac] -g Generate all debugging info
[javac] -g:none Generate no debugging info
[javac] -g:{lines,vars,source} Generate only some debugging info
[javac] -nowarn Generate no warnings
[javac] -verbose ....
BUILD FAILED
H:\jephperro\portlets\CourseList-build.xml:25: Compile failed; see the compiler error output for details.
Total time: 531 milliseconds
What's my problem with Eclipse?
see the compiler error output for details.
You probably have a dependency on a library that was compiled using a later version of Java than your 1.5 JDK.
Actually, where is your 1.5 JDK? All I see is a JRE. My guess is that you just need to download a version 1.5 JDK and add that in Eclipse.
You could create a task in your ant build file that runs the equivalent of java -version so you'll get an idea of which Java compiler is being used by the ant that's started up by Eclipse.
Hint: Your default JRE is a 1.6 JRE. That's fine for running code, but not for compiling. Only a JDK contains the magic required by an external compile (such as done by ant). Eclipse gets around this by including an incremental Java compiler in its own code (more magic).
After years, I still don't fully understand how Eclipse, ant and the JDK interoperate, so maybe you need to do a little experimenting.
AFAIR Eclipse does not use its own internal Java compiler when an Ant file is run. Check your local paths and try to find out which javac is called by Ant.
The 'javac: invalid target release: 1.5' Compilation error is commonly caused by source/binary level incompatibility. Meaning you are trying to compile a source level of JDK 5 with a JDK 1.4 or less.
Eclipse uses a built-in Java compiler. The level actually followed by the compiler depends on the project settings. You can configure the Java level per project or set it as a default at a global level.
From the menu bar, select Window->Preferences. Select the Java->Compiler preference. Set the Compiler Compliance level to 5.0.
As Saifuddin and others mentioned this error is most likely the cause of not using the right Java compiler for the version you want. I notice in your installed JRE's there is a JDK located in DevsuiteHome_1, doesn't say what version. Maybe Ant is using that?
It is very easy to check. You are running ant within Eclipse. Ant has it's own configuration settings that can be different to your workspace. To check the version Ant is using when it runs follow these steps:
Run -> External Tools -> External Tools Configuration -> click on your ant build file (should be created if you ran it once already if not you could always create it here) -> select the JRE Tab -> Verify the runtime you are using