|
From: John G. <jge...@ny...> - 2001-08-27 10:58:44
|
> Hi,
>
> Thanks for the help John. Your statement about focus got me
> thinking. Although my panel is in the same window as the text
> area (don't
> know if this is a no-no or not), and the text area had focus, I
> thought I'd
> try doing something without my panel at all. What I found was
> interesting. I wrote the following test plugin:
>
> So then, I created two shortcuts. The first shortcut is to a macro that
> does the exact same thing (a call to
> textArea.setSelectedText("x")), bound
> to shift-F8. Then I made a shortcut (shift-F7) to the doTest
> action. Sure
> enough, when I hold down shift-F8, the macro call, the line in the text
> area fills up with xxx's as fast as my key-repeat rate. But holding down
> shift-F7, the action call, the app just totally boggs down, slows to a
> crawl. Then looking at the plugin code, I decided to try to extend
> EditPlugin instead of EBPlugin, and sure enough now both calls operate as
> fast as my key-repeat rate. Note, as I mentioned, this is only on
> 3.2pre10. On 3.1final all cases work as expected with no
> slowdown problems.
>
I took this a step further and put a stack trace dump in the action
implementation. Here is a partial dump of the plugin's invocation of the
action:
[debug] TestPlugin: java.lang.RuntimeException: test stack trace
[debug] TestPlugin: at TestPlugin.doTest(TestPlugin.java:14)
[debug] TestPlugin: at java.lang.reflect.Method.invoke(Native Method)
[debug] TestPlugin: at bsh.Reflect.invokeMethod(Reflect.java:355)
[debug] TestPlugin: at bsh.Reflect.invokeStaticMethod(Reflect.java:92)
[debug] TestPlugin: at bsh.Name.invokeMethod(Name.java:696)
[debug] TestPlugin: at
bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:53)
[debug] TestPlugin: at
bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:69)
[debug] TestPlugin: at bsh.BSHBlock.eval(BSHBlock.java:74)
[debug] TestPlugin: at
bsh.BshMethod.invokeDeclaredMethod(BshMethod.java:164)
[debug] TestPlugin: at bsh.NameSpace.invokeMethod(NameSpace.java:1022)
[debug] TestPlugin: at bsh.NameSpace.invokeMethod(NameSpace.java:994)
[debug] TestPlugin: at
org.gjt.sp.jedit.BeanShell.runCachedBlock(BeanShell.java:387)
[debug] TestPlugin: at
org.gjt.sp.jedit.BeanShellAction.invoke(BeanShellAction.java:49)
[debug] TestPlugin: at
org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:188)
[debug] TestPlugin: at
org.gjt.sp.jedit.gui.DefaultInputHandler.keyPressed(DefaultInputHandler.java
:231)
[debug] TestPlugin: at
org.gjt.sp.jedit.textarea.JEditTextArea.processKeyEvent(JEditTextArea.java:4
015)
[debug] TestPlugin: at java.awt.Component.processEvent(Unknown Source)
[debug] TestPlugin: at java.awt.Container.processEvent(Unknown Source)
Now here's the correpsonding dump from the macro:
[debug] XThis: java.lang.RuntimeException: test stack trace
[debug] XThis: at java.lang.reflect.Constructor.newInstance(Native Method)
[debug] XThis: at bsh.Reflect.constructObject(Reflect.java:585)
[debug] XThis: at
bsh.BSHAllocationExpression.constructObject(BSHAllocationExpression.java:103
)
[debug] XThis: at
bsh.BSHAllocationExpression.objectAllocation(BSHAllocationExpression.java:96
)
[debug] XThis: at
bsh.BSHAllocationExpression.eval(BSHAllocationExpression.java:58)
[debug] XThis: at
bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:69)
[debug] XThis: at bsh.BSHArguments.getArguments(BSHArguments.java:47)
[debug] XThis: at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:50)
[debug] XThis: at
bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:69)
[debug] XThis: at bsh.Interpreter.eval(Interpreter.java:588)
[debug] XThis: at org.gjt.sp.jedit.BeanShell.runScript(BeanShell.java:229)
[debug] XThis: at org.gjt.sp.jedit.BeanShell.runScript(BeanShell.java:168)
[debug] XThis: at org.gjt.sp.jedit.Macros$3.invoke(Macros.java:245)
[debug] XThis: at
org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:188)
[debug] XThis: at
org.gjt.sp.jedit.gui.DefaultInputHandler.keyPressed(DefaultInputHandler.java
:231)
[debug] XThis: at
org.gjt.sp.jedit.textarea.JEditTextArea.processKeyEvent(JEditTextArea.java:4
015)
[debug] XThis: at java.awt.Component.processEvent(Unknown Source)
[debug] XThis: at java.awt.Container.processEvent(Unknown Source)
Slava mentioned in another post that he has optmized the use of cached code
by the BeanShell interpreter (see the reference to
BeanShell.runCachedBlock() in the plugin stack). Hopefully this addresses
the problem described here as well as the plugin menu slowdown reported
elsewhere (which I have seen also).
John
|