javac

Java CRTP and Wildcards: Code compiles in Eclipse but not `javac`

扶醉桌前 提交于 2019-12-19 08:34:14
问题 Sorry for the vague title. I have this piece of code which compiles on Eclipse Juno (4.2) but not javac (1.7.0_09): package test; public final class Test { public static class N<T extends N<T>> {} public static class R<T extends N<T>> { public T o; } public <T extends N<T>> void p(final T n) {} public void v(final R<?> r) { p(r.o); // <-- javac fails on this line } } The error is: Test.java:13: error: method p in class Test cannot be applied to given types; p(r.o); ^ required: T found: N<CAP

Java CRTP and Wildcards: Code compiles in Eclipse but not `javac`

前提是你 提交于 2019-12-19 08:34:10
问题 Sorry for the vague title. I have this piece of code which compiles on Eclipse Juno (4.2) but not javac (1.7.0_09): package test; public final class Test { public static class N<T extends N<T>> {} public static class R<T extends N<T>> { public T o; } public <T extends N<T>> void p(final T n) {} public void v(final R<?> r) { p(r.o); // <-- javac fails on this line } } The error is: Test.java:13: error: method p in class Test cannot be applied to given types; p(r.o); ^ required: T found: N<CAP

Method references to raw types harmful?

巧了我就是萌 提交于 2019-12-19 06:04:58
问题 The code below contains a reference to Enum::name (notice no type parameter). public static <T extends Enum<T>> ColumnType<T, String> enumColumn(Class<T> klazz) { return simpleColumn((row, label) -> valueOf(klazz, row.getString(label)), Enum::name); } public static <T, R> ColumnType<T, R> simpleColumn(BiFunction<JsonObject, String, T> readFromJson, Function<T, R> writeToDb) { // ... } Javac reports a warning during compilation: [WARNING] found raw type: java.lang.Enum missing type arguments

Method references to raw types harmful?

一世执手 提交于 2019-12-19 06:04:22
问题 The code below contains a reference to Enum::name (notice no type parameter). public static <T extends Enum<T>> ColumnType<T, String> enumColumn(Class<T> klazz) { return simpleColumn((row, label) -> valueOf(klazz, row.getString(label)), Enum::name); } public static <T, R> ColumnType<T, R> simpleColumn(BiFunction<JsonObject, String, T> readFromJson, Function<T, R> writeToDb) { // ... } Javac reports a warning during compilation: [WARNING] found raw type: java.lang.Enum missing type arguments

Javac can't find class that is in the same directory

给你一囗甜甜゛ 提交于 2019-12-19 03:44:05
问题 I am trying to compile a Java file and I'm getting this error message: $ javac -cp "bc-j-mapi-w-2.4.jar;apache-commons/*;json-org/*;lib/*" BrightcoveVideoQueryPOI.java BrightcoveVideoQueryPOI.java:57: cannot find symbol symbol : class BrightcoveAPI location: class BrightcoveVideoQueryPOI BrightcoveAPI brightcoveAPI = new BrightcoveAPI(BrightcoveAPI.PROD_READ_URL_TOKEN); ^ BrightcoveVideoQueryPOI.java:57: cannot find symbol symbol : class BrightcoveAPI location: class BrightcoveVideoQueryPOI

What is the “Use '--release' option” in IntelliJ 2018.1 preferences?

痴心易碎 提交于 2019-12-18 22:31:11
问题 In the preferences for IntelliJ 2018.1 (Build, Execution, Deployment > Compiler > Java Compiler) is an checkbox labeled: Use '--release' option for cross-compilation (Java 9 and later) I found for information when doing an internet search. The "?" help icon give a 404 error when clicked. What is the purpose/function of this option? 回答1: The help section can be found here: By default, this option is selected. IntelliJ IDEA deduces from project settings when the cross-compilation is needed and

What is sjavac, who is it for and how do I use it?

孤者浪人 提交于 2019-12-18 12:45:06
问题 There has been some buzz about a tool called sjavac on the OpenJDK mailing lists. Also, there are two related JEPs: JEP 139: Enhance javac to Improve Build Speed and JEP 199: Smart Java Compilation, Phase Two. My questions are: What exactly is the sjavac tool? Who is it intended for? How do I use it? Disclaimer: Self answered question. Just wanted to bring the knowledge of this tool to the StackOverflow community and to create a reference to future sjavac FAQ. 回答1: What exactly is the sjavac

How do I find out what jar files are actually used when compiling a java project

a 夏天 提交于 2019-12-18 12:23:54
问题 I'm currently passing a very large classpath to javac to compile a java project. I know that a number of those jar files aren't needed. Is there a simple way of finding out which files aren't needed? 回答1: You need the Class Dependency Analyzer tool. To quote the introduction: The purpose of this tool is to analyze Java™ class files in order to learn more about the dependencies between those classes. True, it won't catch runtime dependencies - but short of running an exhaustive 100% coverage

Why does compiling a class containing static nested classes create a new .class file named “EnclosingClass$1”? [duplicate]

跟風遠走 提交于 2019-12-18 11:46:08
问题 This question already has answers here : Why is an anonymous inner class containing nothing generated from this code? (5 answers) Closed 4 years ago . In the below code : class EnclosingClass { public static class BiNode extends Sub.IBiLink { } private static class Sub { private static class IBiLink { } } } On compiling along with other .class files, I also see a file named "EnclosingClass$1.class" .Why has this been automatically created? Whats going on? 回答1: First have a look at the class

Illegal Character when trying to compile java code

吃可爱长大的小学妹 提交于 2019-12-18 11:44:27
问题 I have a program that allows a user to type java code into a rich text box and then compile it using the java compiler. Whenever I try to compile the code that I have written I get an error that says that I have an illegal character at the beginning of my code that is not there. This is the error the compiler is giving me: C:\Users\Travis Michael>"\Program Files\Java\jdk1.6.0_17\bin\javac" Test.java Test.java:1: illegal character: \187 ∩╗┐public class Test ^ Test.java:1: illegal character: