java.lang.IllegalArgumentException: name can't be empty
at java.security.BasicPermission.init(Unknown Source)
at java.security.BasicPermission.<init>(Unknown Source)
at java.lang.RuntimePermission.<init>(Unknown Source)
at java.lang.Thread.<clinit>(Unknown Source)
I tried various ways of rewriting the above such as adding "private
final boolean tainted[];" and initializing it in each constructor.
Nothing works.
I can add methods to String.java and even the member variable "private
boolean isTainted;" and it works just fine. Do you have any ideas for
why adding a boolean array does not work (or better yet how to get
around this issue)?
Thank you,
Daniel
> I'm trying to modify java.lang.String.java and add the modified
>String.class to
>rt.jar [THIS IS FOR MYSELF ONLY AND WILL NOT BE DEPLOYED].
Try running the VM with
-Xshare:off
If this works re-create the shared archives
(JAVA_HOME/bin/(client|server)/classes.jsa).
HTH
cu
That still does not work. I get the same error.
Well, the offending code seems to be this line in java.lang.Thread:
private static final RuntimePermission
SUBCLASS_IMPLEMENTATION_PERMISSION =
new RuntimePermission("enableContextClassLoaderOverride");
where "new RuntimePermission(...)" results in your observed error if the
supplied string returns 0 for length().
So I would assume, that after you modified java.lang.String the magic
trickery within the VM that creates String objects from String literals in
class files is broken with regard to your modified String class.
I'd try to look there for the problem.
Sorry, that I cannot be of more help.
cu
It is strange that adding "private final boolean tainted[] = new
boolean[5];"
causes a crash bud adding:
"private final boolean tainted=false;" works fine.
If anyone knows more about the internals of how the JVM makes strings
out of string literals I would appreciate a lesson.
> cu- Hide quoted text -
>
> - Show quoted text -
> > - Show quoted text -- Hide quoted text -
Wouldn't it be easier to use WeakHashMap<String,boolean[]> (or something
similar with the map value as a meaningful class type)?
> boolean[5];" to String.java. If I do, it still compiles and I can add
> it to rt.jar and compile a test program against it. However, the JVM
> crashes with a strange message:
>
> java.lang.IllegalArgumentException: name can't be empty
> at java.security.BasicPermission.init(Unknown Source)
> at java.security.BasicPermission.<init>(Unknown Source)
> at java.lang.RuntimePermission.<init>(Unknown Source)
> at java.lang.Thread.<clinit>(Unknown Source)
So if you look at the source, it appears that the literal string
"enableContextClassLoaderOverride" has a length of zero.
As someone else mentioned it will be in the native code loading strings
from class files. The exact details I don't know. Moving your field
after the existing fields might help. It might be that reference fields
are treated differently to primitive fields for object layout.
I suggest your approach is probably poor.
Tom Hawtin
But apart from technical realizability, I think Tom is right; your
approach should not be dependent on the ability to modify the String class.
Regards,
Moritz
I tried instrumentation using JavaAssist and got the same problem. The
reasons for why I want to modify the string class are rather complex
so I'd rather not get into them.