<Swing Dev> Is the following code supposed to leak?
Pavel Porvatov
pavel.porvatov at oracle.com
Thu Aug 25 17:55:27 UTC 2011
Hi Roman,
> Speaking of boundaries, 2 points I would like to add:
>
> - We don't bend the Java specs to prevent System.exit() from exiting, we
> only install a SecurityManager. That is natural, because I don't want
> users of the demos to mess with my server. For example, if you open a
> file dialog in the demo, without the SecurityManager, users would be
> able to modify files on my server. Or terminate the VM. All of which I
> don't want.
> - I noticed that L&F is not set in an AppContext like everything else in
> Swing that would otherwise be a static/global field. This has the funny
> effect that when one user in the demo that I linked sets a different
> L&F, it gets shared to all users, current and future. Very funny.
> However, I have my doubt if that is reasonable behavior, even in more
> normal desktop/applet settings. Wouldn't there be a chance of unwanted
> interference between apps in different appcontexts? Even potential
> security problems? I guess I could design a malicious L&F that could
> exploit the fact that it gets leaked to other AppContexts to do bad
> things (not sure how though, but the fact that it's leaked out sounds a
> bit scary).
About the last point. Take a look at the UIManager#setLookAndFeel method
implementation: it uses AppContext actually... Do you have an example
that shows the problem?
Regards, Pavel
> Roman
>
>
> Am Mittwoch, den 24.08.2011, 16:26 +0400 schrieb Pavel Porvatov:
>> Hi Neugens,
>>> The vm doesn't terminate.
>>>
>>> One VM to rule them all: the instances are separated via the
>>> appcontext, but there is just one server vm running.
>> I'm not sure that's correct behavior. According to javadoc of
>> java.lang.System#exit: "Terminates the currently running Java Virtual
>> Machine.".
>>
>> Regards, Pavel
>>> Cheers,
>>> Mario
>>> --
>>> Sent from HTC Desire...
>>>
>>> pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
>>> Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF
>>>
>>> http://www.icedrobot.org
>>>
>>> Proud GNU Classpath developer: http://www.classpath.org/
>>> Read About us at: http://planet.classpath.org
>>> OpenJDK: http://openjdk.java.net/projects/caciocavallo/
>>>
>>> Please, support open standards:
>>> http://endsoftpatents.org/
>>>
>>>
>>> ----- Reply message -----
>>> Da: "Pavel Porvatov"<pavel.porvatov at oracle.com>
>>> Data: mer, ago 24, 2011 12:57
>>> Oggetto:<Swing Dev> Is the following code supposed to leak?
>>> A: "Clemens Eisserer"<linuxhippy at gmail.com>
>>> Cc:<swing-dev at openjdk.java.net>
>>>
>>>
>>> Hi Clemens,
>>>> Hi Pavel,
>>>>
>>>> In common case you shouldn't remove listeners of course. But
>>> in
>>>> your case you must remove listeners because of editor is
>>> shared
>>>> between all JTextComponents (see javadoc of the
>>>> JTextComponent#getActions method and BasicTextUI#getEditorKit
>>>> implementation). So you added listeners not to a
>>> JTextComponent
>>>> instance, but to the shared editor.
>>>>
>>>>
>>>> Thanks a lot for clarification, I wasn't sure this behaviour is
>>>> intended :/
>>>> Seems I have to adopt the jfc-demo Notepad to not leak memory
>>> when
>>>> running on caciocavallo-web ;)
>>> I took a look at the Notepad demo and didn't find any problems. It
>>> adds
>>> listeners only when the demo starts and there is no need to remove
>>> listeners, because the demo closes via System.exit(0). Could you
>>> please
>>> explain how did you get memory leak in the demo?
>>>
>>> Regards, Pavel
>>>
>>>
>
More information about the swing-dev
mailing list