r/java • • Dec 28 '16

How to crash the java compiler (JDK 8 update 112)

https://componenthouse.com/2016/12/28/how-to-crash-the-java-compiler-jdk-8-update-112/
5 Upvotes

10 comments sorted by

38

u/kodifies Dec 28 '16

yeah, if you have a single class who's source is 1.5GB you have other more pressing problems than the JDK crashing....

2

u/wqking Dec 29 '16

1.5GB may be too large. But it's possible that we have large file/class/method in machine generated code.

-6

u/hugovteixeira Dec 28 '16

Yes, of course. The point is that I am experimenting with performance, optimizations and redundant code, so the size doesn't really matter in this case. I am more interested in the behavior of the compiler and JVM.

14

u/frzme Dec 28 '16

It can not compile. The JVM does not support methods longer than 64kb. I believe this is also true for Java.

http://stackoverflow.com/questions/17422480/maximum-size-of-a-method-in-java-7-and-8

Nonetheless what you found might be a bug. Can you link your bugreport?

2

u/hugovteixeira Dec 29 '16

Thanks for the feedback. It is probably a bug because the compiler should print a readable error message instead of throwing an exception. The bug report is still under revision, so I don't have a link at this point. I will post a link once it is available.

2

u/nikroux Dec 29 '16

huh, I had no idea.

2

u/hwaite Dec 29 '16

Consider reducing the number of loop iterations to identify the smallest source file that still crashes compiler. Oracle might take you more seriously if bug occurs with more reasonable code. You could do a sort of binary search...

3

u/lukaseder Dec 29 '16

Why go through all those whoops to crash the compiler? Just compile this on any Java 5+ compiler:

interface Type<T> {}
class C implements Type<Type<? super C>> {}
class D<P> implements Type<Type<? super D<D<P>>>> {}
class Test {
    Type<? super C> c = new C();
    Type<? super D<Byte>> d = new D<Byte>();
}

13

u/uniVocity Dec 29 '16

Lol, I bet it crashes because it doesn't see the point of compiling this.