Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why transient variable cannot be declared as final or static?

Status
Not open for further replies.

thelordoftherings

Programmer
May 16, 2004
616
IL
a transient variable cannot be declared as final or static"
What is the logic behind this?

 
Are you confusing transient with volatile there stefan ?

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
I would still want to know, if that's possible, how mr LOTR got that error, but I imagine it's the NASA ultrasecret new compiler as he refuses again and again to provide some info about the code or the compiler ...

Cheers,
Dian
 
I think LOTR likes to post a contentious question, then sit back and watch us all argue amongst ourselves :)

I think we should all stop posting until he tells us which compiler he is using. And a link to the exact article that backs up his quote.

Tim
 
That was my tecnique before you started spamming the post :p

Cheers,
Dian
 
As I said again and again it is a herd-copy of SUN and I don't have direct link to it. Send me your email and I'll send you the pdf file. A contentious question?! as I said an understanding question, this doesn't make sence to me either yet I see it at the documentation (and again, I can send the pdf file to proove it). I am using JDK 1.4.2_06 with eclipse interface.
 
Okay I've tried it on JBuilderX and Eclipse3.1 both with JDK1.4.2_10 and neither IDEs complain as you say.

Tim
 
You didn't say it again and again, it's the first time you say your JDK version.

What's the pdf title?

Anyway, I'd delete that pdf: same compiler and IDE as you and still compiling.

Cheers,
Dian
 
And being a commercial book it hasn't more explanations about the sentence?

Cheers,
Dian
 
Here is the exact quote:

transient
The transient modifier is used with variables. It indicates that a variable may not be serialized. It is
typically used to reduce the possibility that an object containing sensitive data might be written to a
stream. A transient variable may not be declared as final or static.

As I said at the begining of the post, it looks strange to me as well and I just want to understand the logic behind this since the statement didn't complied for me as well. Perhaps this is something that can be configured at the JVM?
 
My first thought when I read each one of your post is: "I won't answer him anymore". But let's try again.

This is the first question you should have posted 27 posts ago!

The book says "may", not "can" so I think he talks at a semantic level. If you have sensitive data it doesn't make sense it's static (common to all instances of a class) or final (always the same).

Now, which compile error do you exactly get?

Cheers,
Dian
 
You are right, I apologize, English is not my native tongue.
The compiler error I get is "illegal modifier for the variable...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top