How is this the first time I've heard of Functional Java?
Back to flipping out...
The Home for People Who Like to Flip Out and Write Code
How is this the first time I've heard of Functional Java?
Back to flipping out...
Posted by
Hank Gay
at
15:17
View Comments
Labels: functional_programming, Java, sneak_attack
One of the (in Internet time, at least) golden oldies. Re-reading this makes me cringe when I think back.
Back to flipping out...
Posted by
Hank Gay
at
08:04
View Comments
Labels: Java, python, sneak_attack
Short, easy-to-follow tutorial for Jersey, the Java RI for RESTful web services.
Back to flipping out...
Posted by
Hank Gay
at
13:09
View Comments
Labels: Java, REST, sneak_attack
I'm sure you've all seen the Five Things meme. Here's the five things I hate about Java.
There's just enough generics-related type inferencing to leave me wanting more.
I don't care if there are patterns for doing this, it's not very idiomatic, and the boilerplate obscures the intent of the code, which largely defeats the purpose.
I can't praise the REPL enough. Java should have had one of these in the JDK in 1.0.
The standard library is riddled with checked exceptions that really should have been unchecked, and third-party libraries have followed suit. In fact, Exception should have been unchecked and we should have CheckedException as a subclass instead of RuntimeException.
It's broken. Especially now that Java has covariant returns (thanks Java 5!), this bothers me just often enough that I've forgotten how broken it is right before I need/want it.
This very nearly bumped Array Covariance. I really wish tail-call elimination would catch on in mainstream languages.
Back to flipping out...
Posted by
Hank Gay
at
10:35
View Comments
Labels: five_things_I_hate, Java
Flexjson has been good to me, but every once in a while it jumps up and surprises me. Here's an example.
abstract class AbstractFoo {
private Float a = 1.1f;
private Float b = 2.2f;
private Float c = 3.3f;
public Float getA() {
return a;
}
public Float getB() {
return b;
}
public Float getC() {
return c;
}
}
import flexjson.JSONSerializer;
public final class Foo extends AbstractFoo {
public static void main(final String[] args) {
final Foo myFoo = new Foo();
final JSONSerializer serializer = new JSONSerializer();
System.out.println(serializer.serialize(myFoo));
}
}
Can you guess what you're going to get when you compile this and run java Foo? If you guessed:
{"a":1.1,"b":2.2,"c":3.3,"class":"Foo"}
you were wrong. You really get:
Exception in thread "main" flexjson.JSONException: Error trying to serialize path: [ a ] at flexjson.JSONSerializer$ObjectVisitor.bean(JSONSerializer.java:603) at flexjson.JSONSerializer$ObjectVisitor.json(JSONSerializer.java:471) at flexjson.JSONSerializer$ObjectVisitor.visit(JSONSerializer.java:435) at flexjson.JSONSerializer.serialize(JSONSerializer.java:222) at Foo.main(Foo.java:7) Caused by: java.lang.IllegalAccessException: Class flexjson.JSONSerializer$ObjectVisitor can not access a member of class AbstractFoo with modifiers "public" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65) at java.lang.reflect.Method.invoke(Method.java:578) at flexjson.JSONSerializer$ObjectVisitor.bean(JSONSerializer.java:579) ... 4 more
It appears that Flexjson's serialization algorithm can't handle a package-visible, abstract
super class. Changing it to public
fixes the problem and you can continue on your merry way.
Back to flipping out...
Posted by
Hank Gay
at
13:15
View Comments
Labels: Java