#JavaSyd

Recipe for disaster hacking on Javac

aka ... Hasnae R.

I love it ... but I hate it ... but ...

#JavaSyd

#JavaSyd

" it's clunky and chunky and verbose and ... and ... "

Map<String, Object> data = ImmutableMap.<String, Object>builder()
                .put("key1", "data1")
                .put("key2", 2)
                .put("key3", false)
                .put("nestedKey1", singletonMap("processed", false))
                .put("nestedKey2", ImmutableMap.of(
                        "one", "un", 
                        "two", "deux", 
                        "three", "trois"))
                .put("nestedKey3", asList(2, 3, 5, 7, 11, 13, 17, 19))
                .build();

was the reaction of a JS colleague at the sight of this

#JavaSyd

what if we write it as a JSON String ?

String jsonString = "{" 
                + "`key1` : `data1`," 
                + "`key2` : 2,"
                + "`key3` : false,"
                + "`nestedKey1` : { `processed`: false },"
                + "`nestedKey2` : { `one` : `un`, `two` : `deux` },"
                + "`nestedKey3` : [ 2, 3, 5, 7, 11, 13, 17, 19 ]"
                + "}".replaceAll("`", "\"");
  • reads nicely
  • but prone to errors ...
  • and omg "no multiline string support"

#JavaSyd

Me : let's do some Arts and Crafts ?

Meetup #2 - #JavaSyd - hacking javac

By Luke Thompson

Meetup #2 - #JavaSyd - hacking javac

  • 107