Questions tagged [javac]

javac is the primary Java compiler, included in the Java Development Kit (JDK) from Sun Microsystems (now Oracle), and also in versions from other vendors.

javac is the primary Java compiler, included in the Java Development Kit (JDK) from Sun Microsystems (now Oracle), and also in versions from other vendors.

The compiler accepts source code conforming to the Java language specification (JLS) and produces bytecode conforming to the Java Virtual Machine Specification (JVMS). javac is itself written in Java. The compiler can also be invoked programmatically.

2467 questions
11
votes
3 answers

Correctly install Java for Matlab

I am trying to extract a jar file from Matlab code using javac from Library Compiler (java package). I have set JAVA_HOME to: C:\Program Files\Java\jdk1.7.0_71 and added to PATH: C:\Program Files\Java\jdk1.7.0_71\bin. When I enter java -version…
Jose Ramon
  • 5,572
  • 25
  • 76
  • 152
11
votes
1 answer

Bug in compiler or am I doing something wrong?

First, some environment: this is Oracle's 1.6.0_45 JDK, and IDEA 13.1. I have stumbled upon a most bizarre compiler error: public final class AsmFunnels { private AsmFunnels() { } // ... public static void funnelFieldNode(final…
fge
  • 119,121
  • 33
  • 254
  • 329
11
votes
1 answer

Java annotations - javac compiler bug?

I came across a strange effect in connection with annotations on method parameters in a nested class. Looks very much like a compiler issue to me. See below for details and steps to reproduce. Compile the following class with javac (I used javac…
Stiver
  • 812
  • 5
  • 9
11
votes
5 answers

Should Java programs compiled with debugging information not be used in a production system?

Is there any reason I should avoid compiling in debugging information with Javac in my Java classes for use in a production server? Are there any speed or security concerns I should be aware of? Please note that I am referring to debugging…
James McMahon
  • 48,506
  • 64
  • 207
  • 283
11
votes
2 answers

Method Order in generated class file by javac

With JDK7, the reflection API has changed and now the methods returned by getDeclaredMethods() are not returned in the order in which they are declared in the source file. Now my question is, does the .class file generated by javac contains methods…
Manish
  • 3,913
  • 2
  • 29
  • 45
11
votes
2 answers

Maven2 compiler custom execution source directory and target directory

I want to run the maven compiler plugin in a different phase and with different sourceDirectories and destinationDirectories such that code from directories other than src/main/java and src/test/java can be used. I thought the solution would look…
Paul Keeble
  • 1,202
  • 2
  • 12
  • 16
10
votes
1 answer

What Java code will force javac 1.6 to use the 'swap' and 'nop' opcodes?

I'm working on an amateur JVM implementation, and I'm trying to make sure I have test coverage for all of the opcodes in the spec. I've gotten it down to the last few, but nop and swap have been eluding me. For example, here's a simple function that…
perimosocordiae
  • 17,287
  • 14
  • 60
  • 76
10
votes
3 answers

Javac flag to disallow raw types?

Is there any Java compiler flag that one can pass to tell the compiler to disallow the use of raw types? That is, for any generic class, let the compiler force that the parameterized version be used, and throw a compilation error otherwise?
Kris Nuttycombe
  • 4,560
  • 1
  • 26
  • 29
10
votes
1 answer

OpenJDK 14.0.1 gives "the switch expression does not cover all possible input values"

Using OpenJDK 14.0.1 public class Example { private String test(final ExampleEnum ee) { return switch (ee) { case Value -> null; }; } } public enum ExampleEnum { Value; public enum InnerEnum { …
Matthias
  • 146
  • 1
  • 8
10
votes
1 answer

Why does the compiler choose this generic method with a class type parameter when invoked with an unrelated interface type?

Consider the following two classes and interface: public class Class1 {} public class Class2 {} public interface Interface1 {} Why does the second call to mandatory invoke the overloaded method with Class2, if getInterface1 and Interface1 have no…
froque
  • 442
  • 2
  • 13
10
votes
1 answer

Java 8 nested lambdas break compiler

i have a complex problem with Java 8. Problem With nested lambda compiler crash with a NullPointerException! I know that lambdas must be stateless indeed in this case the codes that have state are Supplier implementations that however are anonymous…
David Geirola
  • 616
  • 3
  • 17
10
votes
2 answers

Why is Java 6 compiled class size larger than Java 5?

We are noticing that when we compile our classes on Java 6, they are consistently larger than Java 5. I understand that there has not been a change to the byte code to date, so I assume the Java 6 compiler is throwing in more stuff. Is that all…
Victor Grazi
  • 15,563
  • 14
  • 61
  • 94
10
votes
2 answers

Why does this code fail to compile, citing type inference as the cause?

Here's a minimal example of the code I'm working with: public class Temp { enum SomeEnum {} private static final Map TEST = new EnumMap<>( Arrays.stream(SomeEnum.values()) …
tterrag
  • 330
  • 2
  • 10
10
votes
1 answer

Why does an incomplete switch expression compile successfully

Trying out JDK/12 EarlyAccess Build 20, where the JEP-325 Switch Expressions has been integrated as a preview feature. A sample code for the expressions (as in the JEP as well): Scanner scanner = new Scanner(System.in); Day day =…
Naman
  • 27,789
  • 26
  • 218
  • 353
10
votes
1 answer

Why can't the eclipse java compiler (ecj) compile this?

I have the following code: package test; import java.util.stream.IntStream; public class A { public static void main(String[] args) { IntStream.range(0, 10).mapToObj(n -> new Object() { int i = n; }).mapToInt(o ->…
Johannes Kuhn
  • 14,778
  • 4
  • 49
  • 73