Start shell
$ ./jshell/pgx.sh
Show predefined variables
package nl.martijndwars.oshell; | |
public class Foo { | |
public static void main(String[] args) throws InterruptedException { | |
Thread thread = new Thread(new Bar()); | |
thread.start(); | |
Thread.sleep(3000); | |
thread.stop(); | |
} |
plugins { | |
id 'java' | |
} | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
compileOnly 'com.google.code.findbugs:jsr305:3.0.2' |
martijn@dhcp-10-175-42-124:/p/t/javatest$ cat Main.java | |
import sun.misc.Unsafe; | |
import java.lang.reflect.Field; | |
public class Main { | |
public static void main(String[] args) throws Exception { | |
Unsafe unsafe = getUnsafe(); | |
System.out.println("Page size = " + unsafe.pageSize()); | |
} |
task C { | |
doLast { | |
println("Do C") | |
} | |
} | |
task A(dependsOn: C) { | |
doLast { | |
println("Do A") | |
} |
Create an empty project with SBT:
sbt new sbt/scala-seed.g8
Update build.sbt
to contain the Metaborg repository:
import Dependencies._
I've always learned that Java 8 streams are lazy. As such, I would expect that:
Optional<Integer> intOpt = Stream
.of(1, 2, 3)
.flatMap(i -> Stream.of(4, 5, 6))
.filter(i -> {System.out.println(i); return true;})
.findAny();
This document explains some aspects of Spoofax that we got questions about. It also describes some common mistakes and pitfalls. Finally, it describes Spoofax' internals more in-depth, with the goal of clarifying some of its behaviour.
test ... [[1+2+3]] parse to [[(1+2)+3]]
. SPT will parse both fragments and compare the ASTs. A common mistake is to introduce a constructor when parsing parenthesized expressions, e.g. Exp.Parens = <(<Exp>)>
. When you make this mistake, the AST for the second fragment will contain Parens
nodes and hence be different from the AST for the first fragment.The solution is to not introduce a constructor. This is semantically cleaner anyway, as a Parens
node does not convey any semantic content (remember: the AST is a tree, not a string, and as such it already encodes what you would otherwise achieve by adding parenthesis). Spoofax will show an error "Missing bracket attribute or constructor name" whi
$(function () { | |
if ('serviceWorker' in navigator) { | |
navigator.serviceWorker.register('/sw.js').then(initialiseState); | |
} else { | |
console.warn('Service workers are not supported in this browser.'); | |
} | |
}); | |
function initialiseState() { | |
if (!('showNotification' in ServiceWorkerRegistration.prototype)) { |