This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Maksim Volf wrote:Feels like it's "sacred" and "forbidden".
Any light on this, please?
I don't know about 'sacred' but it is not part of the public API and thus likely to change from version to version or implementation to implementation. SO you should not rely on its existence. My guess is that you are running on a JRE/JDK which does not have that package or class. And though it may exist in the rt.jar you are looking at it perhaps it does not in the one you compile with. My guess with the framework you are using is that it too is suffering from mis-matched JAR files (parts of the JRE pulled out and run in a different context or something? Class loaders looking at two different lib directories?)
Joined: Jan 23, 2013
No, I swear it's sacred.
produces the output:
but I still can't declare a variable of that type.
Sacred I tell ya!
But I guess you're right about my original research: some jar somewhere is not what it should be... back to square 2.
The first class you showed compiles on my system under but as Steve has already said you shouldn't use them as there is no guarantee they will be available in future releases or other JDK's - see this article
Joined: Jan 23, 2013
At first I was going to let it go and just accept it as sacred. But now that you said it compiles, I got puzzled.
When I just run javacstraight up without any tweaks, it spits out the search path that you can see in my original post, which includes the same rt.jar I'm using, but fails to compile.
Now, when I clear bootclasspath and extdirs as follows:
javac -extdirs . -bootclasspath . -classpath C:\Java\jdk1.6.0_33\jre\lib\rt.jar -verbose One.java
it works all of a sudden.
So, the conclusion is: the other jars in the bootclasspath break the compilation.
But I'm guessing you didn't have to do that to compile it, so my Java is broken in ways I cannot comprehend.
Thanks for your help.
Joined: Aug 07, 2007
I compiled it via Eclipse using "Java(TM) SE Runtime Environment (build 1.6.0_35-b10)"
Sorry I can't be of more help but I have no idea why you are seeing the behaviour you have outlined.