gpt4 book ai didi

java - S4 启动 PE 时数组索引越界

转载 作者:行者123 更新时间:2023-12-01 05:31:30 24 4
gpt4 key购买 nike

我现在正在尝试将一个简单的 PE 添加到我的应用程序中。这个PE扩展了AbstractPE并覆盖了输出方法。(什么也不做)我还修改了 xml 文件,添加了一个 bean,如下所示:

  <bean id="rogerpe" class="cnu.roger.FPActor.RogerPE">                                                                                                                                       
<property name="keys">
<list>
<value>RawTransaction *</value>
</list>
</property>
</bean>

但是,当我尝试运行该平台时。出现一些异常。

Caused by: org.springframework.beans.BeanInstantiationException: 
Could not instantiate bean class [cnu.roger.FPActor.RogerPE]:
Constructor threw exception; nested exception is java.lang.ArrayIndexOutOfBoundsException: -1
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
... 16 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:338)
at java.util.ArrayList.get(ArrayList.java:351)
at io.s4.processor.OverloadDispatcherGenerator.generate(OverloadDispatcherGenerator.java:209)
at io.s4.processor.AbstractPE.<init>(AbstractPE.java:126)
at cnu.roger.FPActor.RogerPE.<init>(RogerPE.java:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
... 18 more

此 PE 的代码:

package cnu.roger.FPActor;                                                                                                                                                                    

import java.util.Collections;
import java.util.List;

import io.s4.processor.AbstractPE;

class RogerPE extends AbstractPE
{
@Override
public void output()
{
// TODO Auto-generated method stub

}
}

我现在很困惑。我不知道它意味着哪个数组。如有任何帮助,我们将不胜感激!

在OverloadDispatcherGenerator.java中

InstructionHandle returnInstruction = il.append(InstructionFactory.createReturn(Type.VOID));                                                                                          

for (int i = 0; i < targetInstructions.size(); i++) {
branchInstructions.get(i).setTarget(targetInstructions.get(i));
}

branchInstructions.get(branchInstructions.size() - 1)
.setTarget(returnInstruction);

for (BranchInstruction gotoInstruction : gotoInstructions) {
gotoInstruction.setTarget(returnInstruction);

}

第 209 行是:branchInstructions.get....

最佳答案

我认为错误代码是:

branchInstructions.get(branchInstructions.size() - 1)                                                                                                                                 
.setTarget(returnInstruction);

如果branchInstructions.size() == 0,则branchInstructions.size() - 1得到-1,但-1是无效索引。

关于java - S4 启动 PE 时数组索引越界,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8904157/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com