|
Authored by: MDT on Sunday, April 22 2012 @ 12:01 AM EDT |
Wrong,
You'd have to write the class loader to specifically look for 'sqrt' with some
other class mapping (Such as math.sqrt) and then substitute your new
science.sqrt in it's place.
The problem is, you would forever break the ability of anyone to write their own
sqrt function, because you'd be overriding the specified path to point it at
science.sqrt.
This is less dangerous if all api calls are fully identified, but if they are
not, then you have the issue.
For example, if I wanted to use java.lang.math.sqrt(), I can specify it that
way. Then the class loader could look specifically for that one, and point it
to science. But, what if I instead wanted to load my.custom.sqrt()? If I've
fully identified i am ok. But nobody writes code like that.
What they do is, they add classes and then just reference the API.
So I would Include my.custom. Then I'd reference sqrt, and since I hadn't
referenced java.lang.math, I'd be fine.
However, if the class loader is going to redirect my call to sqrt to
google.science.sqrt then it will not use my sqrt function.
Could it be possible, maybe. But, it's very very very difficult to pull off
without hosing up the entire system.
---
MDT[ Reply to This | Parent | # ]
|
|
Authored by: jjs on Sunday, April 22 2012 @ 06:06 AM EDT |
At some point, if you write software in Java language, you HAVE to use the Java
API conventions. So if the Java API says java.math.sqrt(), you HAVE to use
java.math.sqrt() in YOUR interface. That may then redirect to
mypackage.science.sqrt(), but the public interface MUST use java.math.sqrt(), or
my software is INCOMPATIBLE with the Java language.
The purpose of the API is to ensure the two use the same words/word order that
means the same thing. Othewise it's like one side of the conversation speaking
english, and the other side speaking chinese. They can have a conversation, but
neither side will understand the other.
---
(Note IANAL, I don't play one on TV, etc, consult a practicing attorney, etc,
etc)
[ Reply to This | Parent | # ]
|
|
|
|
|