shau-lok / google-gson

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

transient access modifier is hidden to Gson object #366

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. when an object is declared as transient, Gson can not observe it.
2. an object that has transient variables, even PUBLIC are hidden
3. converting from json to object with transient variables will give a none 
initialized object

What is the expected output? What do you see instead?
transient variables if declared public should be treated the same as default 
modifier

What version of the product are you using? On what operating system?
java 1.6 / tomcat 7

Please provide any additional information below.
please email me if you need extra information. I had to remove the transient 
modifier to get the library working. which solved the problem. My knowledge of 
transient is that a modifier that informs JVM not to invoke the variable if it 
is in the cache memory which improves the response time as compared with 
volatile which forces the JVM to invoke the variable from the main memory 
regardless of being updated by another thread or not. Please correct me if I am 
wrong

Original issue reported on code.google.com by hussain.mutawa on 24 Sep 2011 at 12:42

GoogleCodeExporter commented 9 years ago
by the way, it took me two hours searching for a cause why the result is not 
shown until I found that the reason was the transient modifier. So,is it a Java 
problem or a bug in Gson?

Original comment by hussain.mutawa on 24 Sep 2011 at 3:57

GoogleCodeExporter commented 9 years ago
Transient has nothing to do with memory caching and everything to do with 
serialization and binding.

You want 'volatile'.

Original comment by limpbizkit on 16 Dec 2011 at 5:03