{"id":16312228,"url":"https://github.com/namin/unsound","last_synced_at":"2025-03-16T14:30:46.083Z","repository":{"id":66551012,"uuid":"65405322","full_name":"namin/unsound","owner":"namin","description":"Artifact for OOPSLA'16 Paper on Unsoundness of Java and Scala","archived":false,"fork":false,"pushed_at":"2023-08-20T20:57:23.000Z","size":263,"stargazers_count":75,"open_issues_count":3,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-08T18:49:14.434Z","etag":null,"topics":["java","meta-theory","oop","scala","unsound"],"latest_commit_sha":null,"homepage":"https://io.livecode.ch/learn/namin/unsound?img=java8","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/namin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-10T18:08:01.000Z","updated_at":"2025-01-21T11:36:20.000Z","dependencies_parsed_at":"2024-10-27T10:53:43.973Z","dependency_job_id":"b380d51e-3e3c-42a2-a66d-aafda6638a5c","html_url":"https://github.com/namin/unsound","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/namin%2Funsound","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/namin%2Funsound/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/namin%2Funsound/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/namin%2Funsound/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/namin","download_url":"https://codeload.github.com/namin/unsound/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243818172,"owners_count":20352629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","meta-theory","oop","scala","unsound"],"created_at":"2024-10-10T21:47:28.007Z","updated_at":"2025-03-16T14:30:46.077Z","avatar_url":"https://github.com/namin.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Artifact for _Java and Scala's Type Systems are Unsound: The Existential Crisis of Null Pointers_\n\nWe provide the three programs as listed in the paper (Amin and Tate, OOPSLA'16 _forthcoming_),\nand step-by-step instructions on how to compile and run them.\nWe also offer \u003ca href=\"http://io.livecode.ch/learn/namin/unsound\"\u003ean interactive playground\u003c/a\u003e.\n\n- `Unsound.java` for Java 8\n- `Unsound9.java` for Java 9\n- `unsound.scala` for Scala\n\nThese short programs demonstrate the unsoundness of Java and\nScala’s current type systems. In particular, these programs provide\nparametrically polymorphic functions that can turn any type into any\ntype without casting. Fortunately, parametric polymorphism was not\nintegrated into the Java Virtual Machine (JVM), so these examples do\nnot demonstrate any unsoundness of the JVM\n\n## Getting Started Guide\n\nYou need JDK 8, JDK 9, Scala 2.11.8.\nYou need to be able to use `javac`, `java`, `scalac`, `scala`.\nYou need to be able to switch between JDK 8 and JDK 9.\nWe give further pointers within the step by step instructions below.\n\n## Step-by-Step Instructions\n\n### Java\n\n#### JDK 8 ([Download](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html))\n\n##### Step 1: Check version\n`java -version`\n\n```\njava version \"1.8.0_25\"\nJava(TM) SE Runtime Environment (build 1.8.0_25-b17)\nJava HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)\n```\n\nIf necessary, switch to JDK 8:\n`export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) ; PATH=$JAVA_HOME/bin:$PATH`\n\n##### Step 2: Compile\n`javac Unsound.java`\n\n_(compiles OK)_\n\n##### Step 3: Run\n`java Unsound`\n\n```\nException in thread \"main\" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String\n  at Unsound.main(Unsound.java:15)\n```\n\n#### JDK 9 ([Download](https://jdk9.java.net/download/))\n\n##### Step 1: Check version\n`java -version`\n\n```\njava version \"9-ea\"\nJava(TM) SE Runtime Environment (build 9-ea+121)\nJava HotSpot(TM) 64-Bit Server VM (build 9-ea+121, mixed mode)\n```\n\nIf necessary, switch to JDK 9:\n`export JAVA_HOME=$(/usr/libexec/java_home -v 9) ; PATH=$JAVA_HOME/bin:$PATH`\n\n##### Step 2: Compile\n`javac Unsound9.java`\n\n_(compiles OK)_\n\nNote that `Unsound.java` does not compile with JDK 9.\n\n`javac Unsound.java`\n\n\n```\nUnsound.java:12: error: method upcast in class Bind\u003cA\u003e cannot be applied to given types;\n    return bind.upcast(constrain, t);\n               ^\n  required: Constrain\u003cU,B\u003e,B\n  found: Constrain\u003cU,CAP#1\u003e,T\n  reason: inference variable B has incompatible bounds\n    upper bounds: U\n    lower bounds: T\n  where U,T,B,A are type-variables:\n    U extends Object declared in method \u003cT,U\u003ecoerce(T)\n    T extends Object declared in method \u003cT,U\u003ecoerce(T)\n    B extends U declared in method \u003cB\u003eupcast(Constrain\u003cA,B\u003e,B)\n    A extends Object declared in class Bind\n  where CAP#1 is a fresh type-variable:\n    CAP#1 extends U super: T from capture of ? super T\n1 error\n```\n\n##### Step 3: Run\n`java Unsound9`\n\n```\nException in thread \"main\" java.lang.ClassCastException: java.lang.Integer (in module: java.base) cannot be cast to java.lang.String (in module: java.base)\n  at Unsound9.main(Unsound9.java:25)\n```\n\n### Scala ([Download](http://downloads.lightbend.com/scala/2.11.8/scala-2.11.8.tgz))\n\n##### Step 1: Check version\n`scala -version`\n\n```\nScala code runner version 2.11.8 -- Copyright 2002-2016, LAMP/EPFL\n```\n\n`java -version`\n\n```\njava version \"1.8.0_25\"\nJava(TM) SE Runtime Environment (build 1.8.0_25-b17)\nJava HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)\n```\n\nScala does not support JDK 9 yet, so switch back to JDK 8 if necessary.\nYou can also switch back to an earlier JDK, e.g. 6, to try the steps with more previous versions of Scala ([download list](http://scala-lang.org/download/all.html)).\nThe earliest version we could get to work with JDK 8 is 2.10.2, and all the releases we sampled in between up to the current milestone 2.12.0-M4 reproduce the remaining steps.\nThe example does not compile in Scala 2.9.3 and earlier due to restrictions on dependent method types. In `unsound_legacy.scala`, we give an example without dependent method types that exhibits the same issue using only features already available in Scala 2.5.0.\n\n##### Step 2: Compile\n`scalac unsound.scala`\n\n_(compiles OK)_\n\n##### Step 3: Run\n\n`scala unsound`\n\n```\njava.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String\n  at unsound$.main(unsound.scala:14)\n  at unsound.main(unsound.scala)\n  at ...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamin%2Funsound","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnamin%2Funsound","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamin%2Funsound/lists"}