chcchangchc / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

too much data exception from javassist #290

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.call mockstatic in test class
2. in the test class unmarshall xml using JAXB. JAXBContext.newInstance call 
fails with the exception. But initialization works fine with easymock and 
issues appear with powermock-easymock-junit extension.

java.lang.RuntimeException: javassist.CannotCompileException: by 
java.io.IOException: too much data
    at org.powermock.core.classloader.MockClassLoader.loadUnmockedClass(MockClassLoader.java:188)
    at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:148)
    at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:65)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:618)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:99)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:144)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:297)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:383)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:348)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:255)
3. I tried with javassist 3.13 and 3.3 , all ended in same exception.

What is the expected output? What do you see instead?
expected output is business class which is mocked

What version of the product are you using? On what operating system?
powermock-easymock-junit-1.4.6.zip 

Please provide any additional information below.

Original issue reported on code.google.com by ssuyam...@gmail.com on 9 Nov 2010 at 4:58

GoogleCodeExporter commented 9 years ago
Issue 291 has been merged into this issue.

Original comment by johan.ha...@gmail.com on 15 Nov 2010 at 7:34

GoogleCodeExporter commented 9 years ago
Hm, which class is it that causes the exception?

Original comment by johan.ha...@gmail.com on 15 Nov 2010 at 7:34

GoogleCodeExporter commented 9 years ago
Hi,
Please see the log and the test attached. Test will give an idea about what I 
am trying. In my application I use the XML data as input. Thats why I 
instantiate JAXB instance in the test class. 

Thanks,
Sundar

log4j:ERROR Could not instantiate appender named "stat".
java.lang.RuntimeException: javassist.CannotCompileException: by 
java.io.IOException: too much data
    at org.powermock.core.classloader.MockClassLoader.loadUnmockedClass(MockClassLoader.java:188)
    at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:148)
    at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:65)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:618)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:99)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:144)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:297)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:383)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:348)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:255)
    at com.lincoln.abob.business.processors.TooMuchDataErrorProof.getTXWrapper(TooMuchDataErrorProof.java:93)
    at com.lincoln.abob.business.processors.TooMuchDataErrorProof.testProcessHistoricAccountValues(TooMuchDataErrorProof.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:322)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
    at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:309)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:297)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:222)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:161)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:135)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:133)
    at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:112)
    at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:57)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: javassist.CannotCompileException: by java.io.IOException: too much 
data
    at javassist.CtClassType.toBytecode(CtClassType.java:1441)
    at javassist.CtClass.toBytecode(CtClass.java:1277)
    at org.powermock.core.classloader.MockClassLoader.loadUnmockedClass(MockClassLoader.java:185)
    ... 41 more
Caused by: java.io.IOException: too much data
    at javassist.ClassPoolTail.copyStream(ClassPoolTail.java:440)
    at javassist.ClassPoolTail.writeClassfile(ClassPoolTail.java:290)
    at javassist.ClassPool.writeClassfile(ClassPool.java:634)
    at javassist.CtClassType.toBytecode(CtClassType.java:1429)
    ... 43 more

Original comment by ssuyam...@gmail.com on 15 Nov 2010 at 3:28

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Johan,
Do you have any update or suggestion on this issue?

Thanks,
Sundar

Original comment by ssuyam...@gmail.com on 17 Nov 2010 at 3:08

GoogleCodeExporter commented 9 years ago
Unfortunately not :/ Perhaps you can try with the latest version of Javassist? 

Original comment by johan.ha...@gmail.com on 27 Dec 2010 at 1:02

GoogleCodeExporter commented 9 years ago
This is a bug with javassist: https://issues.jboss.org/browse/JASSIST-142
It is fixed as of 3.15.0-GA.  

If you're using Maven, the dependency now uses the groupID "org.javassist" 
instead of "javassist" as it did in older versions.

        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.15.0-GA</version>
            <scope>test</scope>
        </dependency>

Original comment by philvar...@gmail.com on 31 Aug 2011 at 6:16

GoogleCodeExporter commented 9 years ago
PowerMock 1.4.10 depends on Javassist 3.15

Original comment by johan.ha...@gmail.com on 31 Aug 2011 at 6:51