javac

Java 1.7 varargs function reported as unchecked warning

十年热恋 提交于 2019-12-01 13:54:12
问题 We use some varargs functions and as we move to java 1.7 we are getting a strange unchecked warning. Function add in interface ICache public interface ICache<O> { void add(Object source, O... objects); } in an interface reports the error. ICache.java:18: warning: [unchecked] Possible heap pollution from parameterized vararg type O void add(Object source, O... objects); where O is a type-variable: O extends Object declared in interface ICache 1 warning O extends Object, as its generic cache

Why does this code compile in Java 1.6 but not in Java 1.7?

一曲冷凌霜 提交于 2019-12-01 13:53:58
问题 The following code compiles fine in Java 1.6 but fails to compile in Java 1.7. Why? The relevant part of the code is the reference to the private 'data' field. The reference is from within the same class in which the field is defined, and so seems legal. But it is happening via a generically-typed variable. This code - a stripped down example based on a class from an in-house library - worked in Java 1.6 but doesn't now in Java 1.7. I'm not asking how to work around this. I've already done

Compile a JDK 8 project + a JDK 9 “module-info.java” in Gradle

亡梦爱人 提交于 2019-12-01 11:09:00
I'm working on a Java library targeting JDK 8, and I'm building it in Gradle 5 using OpenJDK 11. In order to target JDK 8, I'm javac's --release option. However, I'd also like my library to be JPMS-compatible. In other words: I'd like to provide a module-info.class compiled with --release 9 (option 3 in Stephen Colebourne's scale ), while all the rest is compiled with --release 8 . MCVE build.gradle : plugins { id 'java' id 'org.javamodularity.moduleplugin' version '1.4.1' // * } repositories { mavenCentral() } dependencies { compileOnly 'org.projectlombok:lombok:1.18.6' } compileJava.options

Does maven compiler plugin with source 1.6 configuration recognise API introduced since 1.7?

北战南征 提交于 2019-12-01 11:06:26
I've a maven project with the maven-compiler-plugin configured as below: <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> In my code I use a class java.nio.charset.StandardCharsets which is introduced since 1.7. I'm surprised that my code compiles successfully, shouldn't the plugin throw an error because java.nio.charset.StandardCharsets is not 1.6 compilant? Neither target nor source relate in any way to what classes are available on the compiler's classpath. If you're compiling

how to fix Javac invalid flag error?

大城市里の小女人 提交于 2019-12-01 09:13:56
问题 I am trying to compile a an STK applet. Firstly, I would like to compile the .java class by using javac . I am getting an error (invalid flag); this is my command: C:\Program Files (x86)\Java\jdk1.8.0_20\bin>javac C:\Users\user\Desktop\ImsiManager Applet\2014-07-34_ImsiManager_src\2014-07-34_ImsiManager_src\ImsiManager\src\main\java\com\simulity\javacard\imsimanager\ImsiManager.java Javac: invalid flag: C:\Users\user\Desktop\ImsiManager Usage: javac <options> <source files> use -help for a

Does maven compiler plugin with source 1.6 configuration recognise API introduced since 1.7?

折月煮酒 提交于 2019-12-01 08:42:31
问题 I've a maven project with the maven-compiler-plugin configured as below: <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> In my code I use a class java.nio.charset.StandardCharsets which is introduced since 1.7. I'm surprised that my code compiles successfully, shouldn't the plugin throw an error because java.nio.charset.StandardCharsets is not 1.6 compilant? 回答1: Neither target

java compiler options i.e. javac -d

风格不统一 提交于 2019-12-01 08:37:51
问题 I'm compiling a program that has a package statement. e.g. package APPC_LU62.Runtime ; I also have a pre-existing directory structure that matches the package statement. C:\APPC_LU62\Runtime How do I keep the javac compiler from creating the same directory structure within the pre-existing one ? i.e. C:\APPC_LU62\Runtime\APPC_LU62\Runtime It seems to me the compiler ought to be "smart" enough to check first for an existing directory structure before creating one. Thanks 回答1: In general, the

javac not recognized java 7

流过昼夜 提交于 2019-12-01 08:32:59
I have recently installed jdk7 on my windows vista. I have used default installation in C:\Program Files\Java\jdk1.7.0_02\ with javac stored in C:\Program Files\Java\jdk1.7.0_02\bin . I have configured my PATH and CLASSPATH environmental variables (both for my user and system variables) with C:\Program_Files\Java\jdk1.7.0\bin and JAVA_HOME (as my user variable) with C :\Program_Files\Java\jdk1.7.0\ (I have also tried a version with C:\Program_Files\Java\jdk1.7.0_02\bin ). java -version produces desired output. I can also run javac from the C:\Program_Files\Java\jdk1.7.0\bin directory with no

Annotations are only available if source level is 5.0 syntax error java

喜欢而已 提交于 2019-12-01 07:51:33
问题 I am compiling a normal java program with @Override annotation(I downloaded a source from internet from some tutorial). Now the javac is complaing that annotations are only available if source level is 5.0 Every question on SO or other site relates this to eclipse but I am not using eclipse. I am compiling the code from command line. How can I resolve the problem. Here is some information that may be useful: $java -version java version "1.6.0_13-b03 (some other not so useful info) Edit:

javac not recognized java 7

戏子无情 提交于 2019-12-01 07:40:43
问题 I have recently installed jdk7 on my windows vista. I have used default installation in C:\Program Files\Java\jdk1.7.0_02\ with javac stored in C:\Program Files\Java\jdk1.7.0_02\bin . I have configured my PATH and CLASSPATH environmental variables (both for my user and system variables) with C:\Program_Files\Java\jdk1.7.0\bin and JAVA_HOME (as my user variable) with C :\Program_Files\Java\jdk1.7.0\ (I have also tried a version with C:\Program_Files\Java\jdk1.7.0_02\bin ). java -version