1

Some times I see problematic differences between Java doc and Android doc in about method documents.For example in about setReadable (boolean readable, boolean ownerOnly) method you can see java doc says that:

Throws: SecurityException - If a security manager exists and its SecurityManager.checkWrite(java.lang.String) method denies write access to the file

But Android docs does not say any thing about throwing exception.Also we know that Docs say:

Any Exception that can be thrown by a method is part of the method's public programming interface. Those who call a method must know about the exceptions that a method can throw so that they can decide what to do about them.

So when we do not see any throw condition in Android documents of a method,

  1. Does it mean method will not throw exception any way?Or it may be forgotten?
  2. Do we need to check documents for any simple method for probability difference between Java and Android?Is it possible?

Note: I know that

Dalvik, the virtual machine used in Google's Android platform, uses a subset of Harmony for the core of its Class Library.

But I do not think that means possibility of different implementation of a same method in same class.

2

Yes, it is very possible to to have different implementations of the same methods in the same class between Android and Oracle Java.

Remember, Android does not use the JVM. The only similarity between Android's Java and Oracle's Java is the API. Android does not use traditional Java, it uses an API that is "Java-like".

For instance, there is a difference in implementation between Oracle's HTTPURLConnection and Android's HTTPURLConnection. The methods in that class do not behave the same way between platforms.

In your particular example, remember you are comparing two different platforms. The Android platform has a permissions model and a different way to handle file management, so it kind of makes sense why API for file management would differ between the two.

This does not mean that there no similar methods in Android's Java that throw Exceptions, just that this particular one does not. If you are more familiar with Oracle's Java than you are with the Android platform, I would recommend treating the Android platform as different from what you may be used to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.