/hg/icedtea-web: Improve PolicyTool launch method in PolicyPanel
Jiri Vanek
jvanek at redhat.com
Mon Jan 27 06:39:16 PST 2014
...
>> + * @param filePath a {@link String} representing the path of the file to attempt to open
>> + * @throws Exception if any sort of exception occurs during reflective launch of policytool
>> + */
>> + private static void reflectivePolicyToolLaunch(final String filePath) throws Exception {
>> + Class<?> policyTool = Class.forName("sun.security.tools.policytool.PolicyTool");
>
> What about JRE 6? You could catch a ClassNotFoundException here and then try to get
> sun.security.tools.PolicyTool. And, if that fails, well then... Blow up! :-D
Well - why yes? The jdk6 is dead. We are dealing with slowly, but its true. The command exec is what
matters. The second one is fallback.
If you have non-policytool command, non jdk7 system. Please go on and fix. Otherwise I do not
believe it is worthy. And if we will nit pick -what about gnu classpath ? ;)
Maybe some better error message then
JOptionPane.showMessageDialog(frame, message, R("Error"), JOptionPane.ERROR_MESSAGE); ?
except that I agree with all what Jacob pointed out.
>
>> + Class<?>[] signature = new Class<?>[] { String[].class };
>
> Redundant. No need to create a new instance here at run-time.
>
>> + Method main = policyTool.getDeclaredMethod("main", signature);
>
> Just substitute "signature" with "String[].class".
>
>> + Object args = new String[] { "-file", filePath };
>
> Why is "args" of type Object? String[] should be fine and Method.invoke() won't complain because
> String[] inherits from Object. ;-)
>
Especially this.. My overlook.
And yes - the invoke later around the joptionpane is redundant.
Thanx jacob!
>
J.
More information about the distro-pkg-dev
mailing list