Why sun.nio.ch.SelChImpl is not accessable at HotSpot for Java7?
陈雨亭
chenyt at cs.sjtu.edu.cn
Wed Jan 20 10:13:16 UTC 2016
Hello, I rechecked the JVM releases by creating some classes.
Today I created one class and ran it on Oracle's
VM (HotSpot for Java8/Java9) and IBM's VM (J9 for Java8). J9
complains that there is an Exception in thread "main"
java.lang.IllegalAccessError: sun.nio.cs.ext.DoubleByteDecoder.
HotSpot releases do not report any errors.
(It seems that the class starts with sun.* can still be accessible
in JDK9.)
I can understand that J9 is more lazy in format-checking
and verifying a class (I have many cases about this) than HotSpot.
However, this example is a little different. Why is
J9 not compatible to HotSpot in processing this case? Why is
sun.nio.cs.ext.DoubleByteDecoder accessed and checked by
J9 even if the method newDecoder() is not invoked?
Next show the Jimple's code and the decompiled code. The
statement causing the JVM difference is in
public java.nio.charset.CharsetDecoder newDecoder():
...
specialinvoke $r2.<sun.nio.cs.ext.JIS_X_0208$Decoder: void
<init>(java.nio.charset.Charset)>(r0);
...
Yuting
******************************************************
public class M1450718140 extends java.nio.charset.Charset
{
public void <init>()
{
M1450718140 r0;
java.lang.String[] $r1;
r0 := @this: M1450718140;
$r1 = staticinvoke <sun.nio.cs.ext.ExtendedCharsets:
java.lang.String[] aliasesFor(java.lang.String)>("x-JIS0208");
specialinvoke r0.<java.nio.charset.Charset: void
<init>(java.lang.String,java.lang.String[])>("x-JIS0208", $r1);
return;
}
public java.nio.charset.CharsetDecoder newDecoder()
{
M1450718140 r0;
sun.nio.cs.ext.JIS_X_0208$Decoder $r2;
r0 := @this: M1450718140;
$r2 = new sun.nio.cs.ext.JIS_X_0208$Decoder;
specialinvoke $r2.<sun.nio.cs.ext.JIS_X_0208$Decoder: void
<init>(java.nio.charset.Charset)>(r0);
return $r2;
}
public static void main(java.lang.String[])
{
return;
}
}
public class M1450718140 extends java.nio.charset.Charset
minor version: 0
major version: 51
flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
#1 = Class #11 //
sun/nio/cs/ext/ExtendedCharsets
#2 = Utf8 ([Ljava/lang/String;)V
#3 = Utf8 <init>
#4 = Methodref #19.#26 //
java/nio/charset/Charset."<init>":(Ljava/lang/String;[Ljava/lang/String;)V
#5 = Utf8 ()V
#6 = Utf8 Code
#7 = NameAndType #24:#25 //
aliasesFor:(Ljava/lang/String;)[Ljava/lang/String;
#8 = Utf8 main
#9 = Utf8 newDecoder
#10 = Utf8 SourceFile
#11 = Utf8 sun/nio/cs/ext/ExtendedCharsets
#12 = Utf8 ()Ljava/nio/charset/CharsetDecoder;
#13 = Utf8 (Ljava/lang/String;[Ljava/lang/String;)V
#14 = Utf8 Jasmin
#15 = Utf8 sun/nio/cs/ext/JIS_X_0208$Decoder
#16 = Class #15 //
sun/nio/cs/ext/JIS_X_0208$Decoder
#17 = NameAndType #3:#20 //
"<init>":(Ljava/nio/charset/Charset;)V
#18 = String #21 // x-JIS0208
#19 = Class #29 // java/nio/charset/Charset
#20 = Utf8 (Ljava/nio/charset/Charset;)V
#21 = Utf8 x-JIS0208
#22 = Methodref #16.#17 //
sun/nio/cs/ext/JIS_X_0208$Decoder."<init>":(Ljava/nio/charset/Charset;)V
#23 = Utf8 M1450718140
#24 = Utf8 aliasesFor
#25 = Utf8 (Ljava/lang/String;)[Ljava/lang/String;
#26 = NameAndType #3:#13 //
"<init>":(Ljava/lang/String;[Ljava/lang/String;)V
#27 = Class #23 // M1450718140
#28 = Methodref #1.#7 //
sun/nio/cs/ext/ExtendedCharsets.aliasesFor:(Ljava/lang/String;)[Ljava/lang/String;
#29 = Utf8 java/nio/charset/Charset
{
public M1450718140();
descriptor: ()V
flags: ACC_PUBLIC
Code:
stack=3, locals=1, args_size=1
0: aload_0
1: ldc #18 // String x-JIS0208
3: ldc #18 // String x-JIS0208
5: invokestatic #28 // Method
sun/nio/cs/ext/ExtendedCharsets.aliasesFor:(Ljava/lang/String;)[Ljava/lang/String;
8: invokespecial #4 // Method
java/nio/charset/Charset."<init>":(Ljava/lang/String;[Ljava/lang/String;)V
11: return
public java.nio.charset.CharsetDecoder newDecoder();
descriptor: ()Ljava/nio/charset/CharsetDecoder;
flags: ACC_PUBLIC
Code:
stack=3, locals=1, args_size=1
0: new #16 // class
sun/nio/cs/ext/JIS_X_0208$Decoder
3: dup
4: aload_0
5: invokespecial #22 // Method
sun/nio/cs/ext/JIS_X_0208$Decoder."<init>":(Ljava/nio/charset/Charset;)V
8: areturn
public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=0, locals=1, args_size=1
0: return
}
-----Original Message-----
From: Remi Forax
Sent: Sunday, January 03, 2016 6:33 PM
To: 陈雨亭
Cc: hotspot-runtime-dev at openjdk.java.net ; Alan Bateman
Subject: Re: Why sun.nio.ch.SelChImpl is not accessable at HotSpot for
Java7?
And obviously because the class starts with sun.*,
this class is not accessible anymore in JDK 9 (with modules).
Rémi
----- Mail original -----
> De: "陈雨亭" <chenyt at cs.sjtu.edu.cn>
> À: hotspot-runtime-dev at openjdk.java.net, "Alan Bateman"
> <Alan.Bateman at oracle.com>
> Envoyé: Dimanche 3 Janvier 2016 09:43:31
> Objet: Re: Why sun.nio.ch.SelChImpl is not accessable at HotSpot for
> Java7?
>
> Thank you, Alan. I went through the source and got it.
>
> Yuting
>
> -----Original Message-----
> From: Alan Bateman
> Sent: Sunday, January 03, 2016 4:30 PM
> To: 陈雨亭 ; hotspot-runtime-dev at openjdk.java.net
> Subject: Re: Why sun.nio.ch.SelChImpl is not accessable at HotSpot for
> Java7?
>
> On 03/01/2016 08:20, 陈雨亭 wrote:
> > Dear all,
> >
> > I used soot to create the class M1450550406 (see next).
> > HotSpot for Java7 says that M1450550406 cannot access
> > the superinterface sun.nio.ch.SelChImpl, while HotSpot
> > for Java8/9 and J9 for Java8 can access. Could anyone tell
> > me the reason? I checked the package and believed
> > that the interface is in the JRE libraries.
> >
> sun.nio.ch.SelChImpl is a JDK-internal class, it was package-private in
> JDK 7 but was changed to public in JDK 8.
>
> -Alan
>
>
More information about the hotspot-runtime-dev
mailing list