-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.4.1
-
generic
-
generic
Browser: IE/NS6.x
JRE: Hopper based (1.4.1)
Platforms: Win32/Solaris/Linux
According to definition, one is not allowed to access Private and Protected field values of a Java Object from Javascript.
If one does try to then users should be warned to indicate the same.
The only way is to throw JavaScript Exceptions.
Currently if we try to access a private or protected field, it just goes
through the call. No exceptions are thrown.
Now the catch
Say we have Java class "MyApplet" with a private variable 'intval' which is a integer
From an HTML page if we assign
document.MyApplet.intval=2
and check value of 'document.MyApplet.intval', it displays 2.
So we assume that it has set correctly in the Java Object.
Right... No wrong.
If we actually check the value of that private variable using a public method
of that class, we would see that the value is not set to 2.
Only if user uses the Method calls will they get the correct confirmation of whether it is set or not.
Assume
js_x is a javascript variable
applet class name is "MyApplet" with private variable 'intval' whose value is 10
and has a public class 'getInteger()' which 'returns intval'
Assume operations as followes
var js_x = 20
document.MyApplet.intval = js_x
On IE with MSVM
value of document.MyApplet.intval is set to 20
value of document.MyApplet.getInteger() is 10
On IE with Java Plugin
value of document.MyApplet.intval is set to 20
value of document.MyApplet.getInteger() is 10
On NS6 with Java Plugin
value of document.MyApplet.intval is set to 20
value of document.MyApplet.getInteger() is 10
In all cases, no exceptions is thrown.
The strange fact to note is that in Browser the value 20 for document.MyApplet.intval is cached.
It has not allowed to set Private and protected fields, but has done so silently without any warning.
Test case can be accessed from
http://javaweb.sfbay.sun.com/~rpallath/plugin/oji/ojiprivate_field/Test_int_field.html
(Also attached the Testcase)
###@###.### 2004-11-05 22:53:36 GMT
JRE: Hopper based (1.4.1)
Platforms: Win32/Solaris/Linux
According to definition, one is not allowed to access Private and Protected field values of a Java Object from Javascript.
If one does try to then users should be warned to indicate the same.
The only way is to throw JavaScript Exceptions.
Currently if we try to access a private or protected field, it just goes
through the call. No exceptions are thrown.
Now the catch
Say we have Java class "MyApplet" with a private variable 'intval' which is a integer
From an HTML page if we assign
document.MyApplet.intval=2
and check value of 'document.MyApplet.intval', it displays 2.
So we assume that it has set correctly in the Java Object.
Right... No wrong.
If we actually check the value of that private variable using a public method
of that class, we would see that the value is not set to 2.
Only if user uses the Method calls will they get the correct confirmation of whether it is set or not.
Assume
js_x is a javascript variable
applet class name is "MyApplet" with private variable 'intval' whose value is 10
and has a public class 'getInteger()' which 'returns intval'
Assume operations as followes
var js_x = 20
document.MyApplet.intval = js_x
On IE with MSVM
value of document.MyApplet.intval is set to 20
value of document.MyApplet.getInteger() is 10
On IE with Java Plugin
value of document.MyApplet.intval is set to 20
value of document.MyApplet.getInteger() is 10
On NS6 with Java Plugin
value of document.MyApplet.intval is set to 20
value of document.MyApplet.getInteger() is 10
In all cases, no exceptions is thrown.
The strange fact to note is that in Browser the value 20 for document.MyApplet.intval is cached.
It has not allowed to set Private and protected fields, but has done so silently without any warning.
Test case can be accessed from
http://javaweb.sfbay.sun.com/~rpallath/plugin/oji/ojiprivate_field/Test_int_field.html
(Also attached the Testcase)
###@###.### 2004-11-05 22:53:36 GMT
- duplicates
-
JDK-4715685 Exception is not thrown on accessing a non-existent Java field from Javascript.
- Closed