tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howard M. Lewis Ship (JIRA)" <...@tapestry.apache.org>
Subject [jira] Reopened: (TAPESTRY-2551) ArrayIndexOutOfBoundsException in Javassist when using addScript()
Date Wed, 13 Aug 2008 01:11:44 GMT

     [ https://issues.apache.org/jira/browse/TAPESTRY-2551?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Howard M. Lewis Ship reopened TAPESTRY-2551:
--------------------------------------------

      Assignee: Howard M. Lewis Ship

> ArrayIndexOutOfBoundsException in Javassist when using addScript()
> ------------------------------------------------------------------
>
>                 Key: TAPESTRY-2551
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2551
>             Project: Tapestry
>          Issue Type: Bug
>    Affects Versions: 5.0.13
>         Environment: Version
>     5.0.13
>            Reporter: Andy Blower
>            Assignee: Howard M. Lewis Ship
>
> I'm converting inline JS to addScript method calls in the Java as you suggested. So far
this has been a real pain, which is especially galling since it was working just fine to my
mind. Anyhow, I have the following in my Java:
> 	@CleanupRender
> 	void initClickEventsJS()
> 	{
> //		renderSupport.addScript("for (int i=1; i <= %d; i++) { ", filterIdx);
> //		renderSupport.addScript("var filterHeader = $('filter' + i + '-header');");
> //		renderSupport.addScript("var filterDiv = $('filter' + i + '-div');");
> //		renderSupport.addScript("filterHeader.observe('click', toggleFilter.bindAsEventListener(filterHeader,
filterDiv)); };");
> 		
> 		for (int i = 1; i <= filterIdx; i++) {
> 			renderSupport.addScript("var filterHeader = $('filter%d-header');", i);
> 			renderSupport.addScript("var filterDiv = $('filter%d-div');", i);
> 			renderSupport.addScript("filterHeader.observe('click', toggleFilter.bindAsEventListener(filterHeader,
filterDiv));");
> 		}
> 	}
> The commented out bit wont work because of TAPESTRY-2429, so I'm trying to get the for
loop working in the Java code instead but it fails with the huge stack trace below. If, however,
I add a second parameter to the last addScript method call it seems to work.
>     * java.lang.ClassNotFoundException
>       caught an exception while obtaining a class file for com.proquest.apps.corelib.components.SimpleResultsFilters
>       exception
>           org.apache.tapestry5.internal.services.TransformationException: 7
>     * org.apache.tapestry5.internal.services.TransformationException
>       7
>       transformation
>           InternalClassTransformation[
>           public com.proquest.apps.corelib.components.SimpleResultsFilters extends com.proquest.apps.corelib.base.ResultsFilterBase
>           add field: private java.util.Map _$getAppliedFilters;
>           add field: private boolean _$getAppliedFilters$called;
>           add field: private org.apache.tapestry5.Binding _$getAppliedFilters$binding;
>           add field: private java.lang.Object _$getAppliedFilters$bindingValue;
>           add field: protected final org.apache.tapestry5.services.BindingSource _$getAppliedFilters$bindingsource;
>           extend method: public void containingPageDidLoad()
>           _$getAppliedFilters$binding = _$getAppliedFilters$bindingsource.newBinding("Watch
expression", _$resources, "prop", "grouper");
>           extend method: public void containingPageDidDetach()
>           {
>             _$getAppliedFilters = null;
>             _$getAppliedFilters$called = false;
>             _$getAppliedFilters$bindingValue = null;
>           }
>           prefix method: public java.util.Map getAppliedFilters()
>           {
>             if (_$getAppliedFilters$called && _$getAppliedFilters$bindingValue
== _$getAppliedFilters$binding.get()) return _$getAppliedFilters;
>             _$getAppliedFilters$bindingValue = _$getAppliedFilters$binding.get();
>             _$getAppliedFilters$called = true;
>           }
>           extend existing method: public java.util.Map getAppliedFilters()
>           {
>             _$getAppliedFilters = $_;
>           }
>           add field: private java.util.List _$getFilterGroupings;
>           add field: private boolean _$getFilterGroupings$called;
>           add field: private org.apache.tapestry5.Binding _$getFilterGroupings$binding;
>           add field: private java.lang.Object _$getFilterGroupings$bindingValue;
>           extend method: public void containingPageDidLoad()
>           _$getFilterGroupings$binding = _$getAppliedFilters$bindingsource.newBinding("Watch
expression", _$resources, "prop", "filters");
>           extend method: public void containingPageDidDetach()
>           {
>             _$getFilterGroupings = null;
>             _$getFilterGroupings$called = false;
>             _$getFilterGroupings$bindingValue = null;
>           }
>           prefix method: public java.util.List getFilterGroupings()
>           {
>             if (_$getFilterGroupings$called && _$getFilterGroupings$bindingValue
== _$getFilterGroupings$binding.get()) return _$getFilterGroupings;
>             _$getFilterGroupings$bindingValue = _$getFilterGroupings$binding.get();
>             _$getFilterGroupings$called = true;
>           }
>           extend existing method: public java.util.List getFilterGroupings()
>           {
>             _$getFilterGroupings = $_;
>           }
>           add method: private void _$write_LOGGER_0(org.slf4j.Logger $1)
>           throw new java.lang.RuntimeException("Field com.proquest.apps.corelib.components.SimpleResultsFilters.LOGGER
is read-only.");
>           replace write LOGGER: _$write_LOGGER_0();
>           add method: private void _$write_messages(org.apache.tapestry5.ioc.Messages
$1)
>           throw new java.lang.RuntimeException("Field com.proquest.apps.corelib.components.SimpleResultsFilters.messages
is read-only.");
>           replace write messages: _$write_messages();
>           extend method: public boolean dispatchComponentEvent(org.apache.tapestry5.runtime.ComponentEvent
$1)
>           {
>             if ($1.isAborted()) return $_;
>             try
>             {
>               if ($1.matches("filter", "", 2))
>               {
>                 $_ = true;
>                 $1.setMethodDescription("com.proquest.apps.corelib.components.SimpleResultsFilters.doFilter(java.lang.String,
java.lang.String) (at SimpleResultsFilters.java:184)");
>                 doFilter((java.lang.String)$1.coerceContext(0, "java.lang.String"), (java.lang.String)$1.coerceContext(1,
"java.lang.String"));
>               }
>               if ($1.matches("unfilter", "", 2))
>               {
>                 $_ = true;
>                 $1.setMethodDescription("com.proquest.apps.corelib.components.SimpleResultsFilters.removeFilter(java.lang.String,
java.lang.String) (at SimpleResultsFilters.java:196)");
>                 removeFilter((java.lang.String)$1.coerceContext(0, "java.lang.String"),
(java.lang.String)$1.coerceContext(1, "java.lang.String"));
>               }
>             }
>             catch (RuntimeException ex) { throw ex; }
>             catch (Exception ex) { throw new RuntimeException(ex); } 
>           }
>           add field: private boolean _$filters_cached;
>           add field: private java.lang.String _$filters_default;
>           add field: private boolean _$filters_invariant;
>           extend method: public void containingPageDidLoad()
>           {
>             _$filters_invariant = _$resources.isInvariant("filters");
>             _$filters_default = filters;
>           }
>           extend method: public void postRenderCleanup()
>           if (! _$filters_invariant)
>           {
>             filters = _$filters_default;
>             _$filters_cached = false;
>           }
>           add method: private java.lang.String _$read_parameter_filters()
>           {
>             if (_$filters_cached || ! _$resources.isLoaded() || ! _$resources.isBound("filters"))
return filters;
>             java.lang.String result = ($r) ((java.lang.String) _$resources.readParameter("filters",
"java.lang.String"));
>             if (_$filters_invariant || _$resources.isRendering())
>             {
>               filters = result;
>               _$filters_cached = true;
>             }
>             return result;
>           }
>           replace read filters: _$read_parameter_filters();
>           add method: private void _$update_parameter_filters(java.lang.String $1)
>           {
>             if (! _$resources.isLoaded())
>             {
>               filters = $1;
>               return;
>             }
>             if (_$resources.isBound("filters"))
>               _$resources.writeParameter("filters", ($w)$1);
>             filters = $1;
>             _$filters_cached = _$resources.isRendering();
>           }
>           replace write filters: _$update_parameter_filters();
>           add field: private boolean _$results_cached;
>           add field: private com.proquest.apps.corelib.search.ResultsList _$results_default;
>           add field: private boolean _$results_invariant;
>           extend method: public void containingPageDidLoad()
>           {
>             _$results_invariant = _$resources.isInvariant("source");
>             _$results_default = results;
>           }
>           extend method: public void postRenderCleanup()
>           if (! _$results_invariant)
>           {
>             results = _$results_default;
>             _$results_cached = false;
>           }
>           add method: private com.proquest.apps.corelib.search.ResultsList _$read_parameter_source()
>           {
>             if (_$results_cached || ! _$resources.isLoaded() || ! _$resources.isBound("source"))
return results;
>             com.proquest.apps.corelib.search.ResultsList result = ($r) ((com.proquest.apps.corelib.search.ResultsList)
_$resources.readParameter("source", "com.proquest.apps.corelib.search.ResultsList"));
>             if (_$results_invariant || _$resources.isRendering())
>             {
>               results = result;
>               _$results_cached = true;
>             }
>             return result;
>           }
>           replace read results: _$read_parameter_source();
>           add method: private void _$update_parameter_source(com.proquest.apps.corelib.search.ResultsList
$1)
>           {
>             if (! _$resources.isLoaded())
>             {
>               results = $1;
>               return;
>             }
>             if (_$resources.isBound("source"))
>               _$resources.writeParameter("source", ($w)$1);
>             results = $1;
>             _$results_cached = _$resources.isRendering();
>           }
>           replace write results: _$update_parameter_source();
>           add method: public void setupRender(org.apache.tapestry5.MarkupWriter $1, org.apache.tapestry5.runtime.Event
$2)
>           {
>             super.setupRender($$);
>             if ($2.isAborted()) return;
>             try
>             {
>               $2.setMethodDescription("com.proquest.apps.corelib.components.SimpleResultsFilters.initFilterList()
(at SimpleResultsFilters.java:80)");
>               if ($2.storeResult(($w) initFilterList())) return;
>             }
>             catch (RuntimeException ex) { throw ex; }
>             catch (Exception ex) { throw new RuntimeException(ex); }
>           }
>           add method: public void beginRender(org.apache.tapestry5.MarkupWriter $1, org.apache.tapestry5.runtime.Event
$2)
>           {
>             super.beginRender($$);
>             if ($2.isAborted()) return;
>             try
>             {
>               $2.setMethodDescription("com.proquest.apps.corelib.components.SimpleResultsFilters.nextFilter()
(at SimpleResultsFilters.java:88)");
>               nextFilter();
>             }
>             catch (RuntimeException ex) { throw ex; }
>             catch (Exception ex) { throw new RuntimeException(ex); }
>           }
>           add method: public void afterRender(org.apache.tapestry5.MarkupWriter $1, org.apache.tapestry5.runtime.Event
$2)
>           {
>             try
>             {
>               $2.setMethodDescription("com.proquest.apps.corelib.components.SimpleResultsFilters.moreFilters()
(at SimpleResultsFilters.java:97)");
>               if ($2.storeResult(($w) moreFilters())) return;
>               super.afterRender($$);
>             }
>             catch (RuntimeException ex) { throw ex; }
>             catch (Exception ex) { throw new RuntimeException(ex); }
>           }
>           add method: public void cleanupRender(org.apache.tapestry5.MarkupWriter $1,
org.apache.tapestry5.runtime.Event $2)
>           {
>             try
>             {
>               $2.setMethodDescription("com.proquest.apps.corelib.components.SimpleResultsFilters.initClickEventsJS()
(at SimpleResultsFilters.java:108)");
>               initClickEventsJS();
>               super.cleanupRender($$);
>             }
>             catch (RuntimeException ex) { throw ex; }
>             catch (Exception ex) { throw new RuntimeException(ex); }
>           }
>           add field: protected final org.apache.tapestry5.internal.services.ComponentResourcesOperation
_$operation;
>           extend method: public void setupRender(org.apache.tapestry5.MarkupWriter $1,
org.apache.tapestry5.runtime.Event $2)
>           _$operation.perform(_$resources);
>           add field: protected final org.apache.tapestry5.internal.services.ComponentResourcesOperation
_$operation_0;
>           extend method: public void setupRender(org.apache.tapestry5.MarkupWriter $1,
org.apache.tapestry5.runtime.Event $2)
>           _$operation_0.perform(_$resources);
>           add transformed method: public final int getFilterIdx()
>           return filterIdx;
>           add transformed method: public final void setFilterIdx(int $1)
>           filterIdx = $1;
>           add transformed method: public final java.util.List getFilterList()
>           return filterList;
>           add transformed method: public final void setFilterList(java.util.List $1)
>           filterList = $1;
>           add transformed method: public final java.lang.String getFilters()
>           return filters;
>           add field: protected final org.apache.tapestry5.services.Environment _$environment;
>           add method: private org.apache.tapestry5.RenderSupport _$environment_read_renderSupport()
>           return ($r) _$environment.peekRequired($type);
>           replace read renderSupport: _$environment_read_renderSupport();
>           add method: private void _$write_renderSupport(org.apache.tapestry5.RenderSupport
$1)
>           throw new java.lang.RuntimeException("Field com.proquest.apps.corelib.components.SimpleResultsFilters.renderSupport
is read-only.");
>           replace write renderSupport: _$write_renderSupport();
>           remove field renderSupport;
>           add field: private int _$filterIdx_default;
>           extend method: public void containingPageDidLoad()
>           _$filterIdx_default = filterIdx;
>           extend method: public void containingPageDidDetach()
>           filterIdx = _$filterIdx_default;
>           add field: private java.util.Iterator _$filterIter_default;
>           extend method: public void containingPageDidLoad()
>           _$filterIter_default = filterIter;
>           extend method: public void containingPageDidDetach()
>           filterIter = _$filterIter_default;
>           add field: private java.util.List _$filterList_default;
>           extend method: public void containingPageDidLoad()
>           _$filterList_default = filterList;
>           extend method: public void containingPageDidDetach()
>           filterList = _$filterList_default;
>           Checking field write filterIter in method initFilterList(): field not transformed
>           Checking field write filterIdx in method initFilterList(): field not transformed
>           Checking field read filterIter in method initFilterList(): field not transformed
>           Checking field read filterIter in method nextFilter(): field not transformed
>           Checking field write filterList in method nextFilter(): field not transformed
>           Checking field read filterIdx in method nextFilter(): field not transformed
>           Checking field write filterIdx in method nextFilter(): field not transformed
>           Checking field read filterIter in method moreFilters(): field not transformed
>           Checking field read renderSupport in method initClickEventsJS(): replacing
with $_ = $0._$environment_read_renderSupport();
>           ]
>     * java.lang.ArrayIndexOutOfBoundsException
>       7
>       Stack trace
>               o javassist.bytecode.ByteArray.write16bit(ByteArray.java:40)
>               o javassist.bytecode.StackMapTable$Shifter.update(StackMapTable.java:744)
>               o javassist.bytecode.StackMapTable$Shifter.sameFrame(StackMapTable.java:720)
>               o javassist.bytecode.StackMapTable$Walker.stackMapFrames(StackMapTable.java:194)
>               o javassist.bytecode.StackMapTable$Walker.parse(StackMapTable.java:179)
>               o javassist.bytecode.StackMapTable$Shifter.doit(StackMapTable.java:714)
>               o javassist.bytecode.StackMapTable.shiftPc(StackMapTable.java:693)
>               o javassist.bytecode.CodeIterator.insertGap0(CodeIterator.java:676)
>               o javassist.bytecode.CodeIterator.insertGap(CodeIterator.java:636)
>               o javassist.bytecode.CodeIterator.insertGapCore(CodeIterator.java:467)
>               o javassist.bytecode.CodeIterator.insertGap(CodeIterator.java:413)
>               o javassist.expr.Expr.replace0(Expr.java:298)
>               o javassist.expr.FieldAccess.replace(FieldAccess.java:213)
>               o org.apache.tapestry5.internal.services.InternalClassTransformationImpl$2.edit(InternalClassTransformationImpl.java:1685)
>               o javassist.expr.ExprEditor.loopBody(ExprEditor.java:197)
>               o javassist.expr.ExprEditor.doit(ExprEditor.java:90)
>               o javassist.CtClassType.instrument(CtClassType.java:1289)
>               o org.apache.tapestry5.internal.services.InternalClassTransformationImpl.replaceFieldAccess(InternalClassTransformationImpl.java:1691)
>               o org.apache.tapestry5.internal.services.InternalClassTransformationImpl.performFieldTransformations(InternalClassTransformationImpl.java:1619)
>               o org.apache.tapestry5.internal.services.InternalClassTransformationImpl.finish(InternalClassTransformationImpl.java:1298)
>               o org.apache.tapestry5.internal.services.ComponentClassTransformerImpl.transformComponentClass(ComponentClassTransformerImpl.java:160)
>               o org.apache.tapestry5.internal.services.ComponentInstantiatorSourceImpl.onLoad(ComponentInstantiatorSourceImpl.java:171)
>               o javassist.Loader.findClass(Loader.java:340)
>               o org.apache.tapestry5.internal.services.ComponentInstantiatorSourceImpl$PackageAwareLoader.findClass(ComponentInstantiatorSourceImpl.java:78)
>               o javassist.Loader.loadClass(Loader.java:311)
>               o java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>               o java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>               o java.lang.Class.getDeclaredMethods0(Native Method)
>               o java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
>               o java.lang.Class.getDeclaredMethods(Class.java:1791)
>               o java.beans.Introspector$1.run(Introspector.java:1272)
>               o java.security.AccessController.doPrivileged(Native Method)
>               o java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1270)
>               o java.beans.Introspector.getTargetMethodInfo(Introspector.java:1136)
>               o java.beans.Introspector.getBeanInfo(Introspector.java:387)
>               o java.beans.Introspector.getBeanInfo(Introspector.java:159)
>               o org.apache.tapestry5.ioc.internal.services.PropertyAccessImpl.buildAdapter(PropertyAccessImpl.java:84)
>               o org.apache.tapestry5.ioc.internal.services.PropertyAccessImpl.getAdapter(PropertyAccessImpl.java:65)
>               o org.apache.tapestry5.internal.services.PropertyConduitSourceImpl.readInfoForTerm(PropertyConduitSourceImpl.java:459)
>               o org.apache.tapestry5.internal.services.PropertyConduitSourceImpl.writePropertyNavigationCode(PropertyConduitSourceImpl.java:281)
>               o org.apache.tapestry5.internal.services.PropertyConduitSourceImpl.buildGetter(PropertyConduitSourceImpl.java:217)
>               o org.apache.tapestry5.internal.services.PropertyConduitSourceImpl.build(PropertyConduitSourceImpl.java:174)
>               o org.apache.tapestry5.internal.services.PropertyConduitSourceImpl.create(PropertyConduitSourceImpl.java:120)
>               o org.apache.tapestry5.internal.bindings.PropBindingFactory.newBinding(PropBindingFactory.java:48)
>               o org.apache.tapestry5.internal.services.BindingSourceImpl.newBinding(BindingSourceImpl.java:78)
>               o org.apache.tapestry5.internal.services.PageElementFactoryImpl.newExpansionElement(PageElementFactoryImpl.java:176)
>               o org.apache.tapestry5.internal.services.PageLoaderProcessor.expansion(PageLoaderProcessor.java:356)
>               o org.apache.tapestry5.internal.services.PageLoaderProcessor.loadTemplateForComponent(PageLoaderProcessor.java:489)
>               o org.apache.tapestry5.internal.services.PageLoaderProcessor.workComponentQueue(PageLoaderProcessor.java:808)
>               o org.apache.tapestry5.internal.services.PageLoaderProcessor.loadPage(PageLoaderProcessor.java:393)
>               o org.apache.tapestry5.internal.services.PageLoaderImpl.loadPage(PageLoaderImpl.java:59)
>               o org.apache.tapestry5.internal.services.PagePoolCache.checkout(PagePoolCache.java:210)
>               o org.apache.tapestry5.internal.services.PagePoolImpl.checkout(PagePoolImpl.java:107)
>               o org.apache.tapestry5.internal.services.RequestPageCacheImpl.get(RequestPageCacheImpl.java:43)
>               o org.apache.tapestry5.internal.services.RequestSecurityManagerImpl.checkForInsecureRequest(RequestSecurityManagerImpl.java:59)
>               o org.apache.tapestry5.services.TapestryModule$28.handle(TapestryModule.java:1670)
>               o org.apache.tapestry5.internal.services.PageRenderDispatcher.process(PageRenderDispatcher.java:97)
>               o org.apache.tapestry5.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:73)
>               o org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938)
>               o org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42)
>               o org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586)
>               o org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
>               o org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79)
>               o com.proquest.apps.corelib.AppCoreLibModule$1.service(AppCoreLibModule.java:84)
>               o org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
>               o org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
>               o org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:75)
>               o org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
>               o org.apache.tapestry5.services.TapestryModule$11.service(TapestryModule.java:918)
>               o org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
>               o org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:168)
>               o org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>               o org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
>               o org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>               o org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>               o org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:722)
>               o org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:404)
>               o org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>               o org.mortbay.jetty.Server.handle(Server.java:324)
>               o org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
>               o org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
>               o org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
>               o org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
>               o org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
>               o org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
>               o org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Mime
View raw message