Skip to content

Instantly share code, notes, and snippets.

@etorreborre
Created November 22, 2011 21:50
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save etorreborre/1387113 to your computer and use it in GitHub Desktop.
Save etorreborre/1387113 to your computer and use it in GitHub Desktop.
An example of a non-terminating compilation with javac
/** from http://www.reddit.com/r/programming/comments/mlbna/scala_feels_like_ejb_2/c31z0co */
interface Pong<T> {}
class Ping<T> implements Pong<Pong<? super Ping<Ping<T>>>> {
static void Ping() {
Pong<? super Ping<Long>> Ping = new Ping<Long>();
}
}
> javac Ping.java
The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:568)
at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3294)
at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2618)
at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2605)
at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:568)
at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3294)
at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2618)
at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2605)
at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:568)
at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3294)
at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2618)
at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2605)
at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:568)
at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3294)
at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2618)
at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2605)
@mozillanerd
Copy link

Fun with Generics

@agentgt
Copy link

agentgt commented Nov 23, 2011

I have done this before for my little pet project JATL.

@pathikrit
Copy link

class <___>{}class <>extends <<?super **<<___>>>>{void (){<? super _<>>=new ___<**>();}}

@pathikrit
Copy link

class $&lt;__&gt;{}class €&lt;£&gt;extends $&lt;$<?super €<€<£>>>>{void $(){$&lt;? super €<$>>$=new €<$>();}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment