samujjwal / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Throw exception on type adapter registration for non overridable built-in type adapter #429

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Gson g = new GsonBuilder().registerTypeAdapter(String.class, new 
JsonSerializer<String>() {

    public JsonElement serialize(String src, Type typeOfSrc, JsonSerializationContext context) {
        return new JsonPrimitive(src.toUpperCase());
    }

}).create();
System.out.println(g.toJson("test"));

What is the expected output? What do you see instead?
I expect that an exception should be thrown. Instead i see:
"test"

What version of the product are you using? On what operating system?
2.1 on Ubuntu 11.10 x64

Original issue reported on code.google.com by Ash2kk@gmail.com on 1 Apr 2012 at 9:02

GoogleCodeExporter commented 9 years ago
Worth looking into in 2.2.

Original comment by limpbizkit on 11 Apr 2012 at 8:35

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 12 Apr 2012 at 6:29