gpt4 book ai didi

JAVA: java.lang.IllegalArgumentException: 不能继承最终类类 [Lcom.package.testEntityDO;

转载 作者:搜寻专家 更新时间:2023-10-31 20:01:06 27 4
gpt4 key购买 nike

我正在尝试模拟下课。

 public class testEntityDO extends BasetestDO {
private String entityType;
private testCapabilityDO[] capabilities;
private testEntityDO[] testDOs;
public String getEntityType() {
return entityType;
}
public void setEntityType(String entityType) {
this.entityType = entityType;
}
public testCapabilityDO[] getCapabilities() {
return capabilities;
}
public void setCapabilities(testCapabilityDO[] capabilities) {
this.capabilities = capabilities;
}
public TestEntityDO[] getTestPortDOs() {
return testPortDOs;
}
public void setTestPortDOs(TestEntityDO[] testPortDOs) {
this.testPortDOs = testPortDOs;
}
}

被模拟的代码:

TestEntityDO[] testEntityMock = testmethod.getTestEntityDO();

我试过的模拟:

TestEntityDO[] testEntityDOMock  = PowerMock.createMock(TestEntityDO[].class); // exception is generating at this point
EasyMock.expect(testmethod.getTestEntityDO()).andReturn(testEntityDOMock);

异常跟踪:

java.lang.IllegalArgumentException: Cannot subclass final class class [Lcom.package.TestEntityDO;
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:446)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)

类不是最终类。仍然将异常指向最后一个类。请帮我解决这个问题。

最佳答案

您正在尝试创建 TestEntityDO 数组的子类/模拟。数组是最终的。

关于JAVA: java.lang.IllegalArgumentException: 不能继承最终类类 [Lcom.package.testEntityDO;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33331150/

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