jocarreira / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

Cannot use hamcrest-all.jar on android #145

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When I include hamcrest-all.jar for Android I get a failure when it tries to 
translate to dalvik code. The error occurs because of the JFlexParser and seems 
to be that it is generated code that violates some rule with local variables. 
Here is the specific error from the console:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.code.SimException: local variable type mismatch: attempt to 
set or access a value of type java.lang.Object using a local variable of type 
int. This is symptomatic of .class transformation tools that ignore local 
variable information.
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.cf.code.BaseMachine.throwLocalMismatch(BaseMachine.java:550)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.cf.code.Simulator$SimVisitor.visitLocal(Simulator.java:570)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:481)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.cf.code.Simulator.simulate(Simulator.java:99)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.cf.code.Ropper.processBlock(Ropper.java:684)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.cf.code.Ropper.doit(Ropper.java:639)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.cf.code.Ropper.convert(Ropper.java:252)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:252)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:131)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:85)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.command.dexer.Main.processClass(Main.java:369)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.command.dexer.Main.processFileBytes(Main.java:346)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.command.dexer.Main.access$400(Main.java:59)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:294)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244
)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.command.dexer.Main.processOne(Main.java:313)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.command.dexer.Main.processAllFiles(Main.java:233)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.dx.command.dexer.Main.run(Main.java:185)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
java.lang.reflect.Method.invoke(Method.java:597)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:179)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.jav
a:585)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(Po
stCompilerBuilder.java:490)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:3
11)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
[2011-04-12 10:16:57 - Android-libmpg_Test] Dx  at 
org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
...at bytecode offset 0000001b
locals[0000]: Lorg/hamcrest/generator/qdox/parser/impl/JFlexLexer;
locals[0001]: I
locals[0002]: [C
locals[0003]: [C
locals[0004]: [I
locals[0005]: [I
locals[0006]: <invalid>
locals[0007]: <invalid>
locals[0008]: <invalid>
locals[0009]: <invalid>
locals[000a]: <invalid>
locals[000b]: <invalid>
locals[000c]: <invalid>
locals[000d]: <invalid>
locals[000e]: <invalid>
locals[000f]: <invalid>
locals[0010]: <invalid>
stack[top0]: [B
...while working on block 001b
...while working on method yylex:()I
...while processing yylex ()I
...while processing org/hamcrest/generator/qdox/parser/impl/JFlexLexer.class

Original issue reported on code.google.com by dalewk...@gmail.com on 12 Apr 2011 at 2:27

GoogleCodeExporter commented 8 years ago
Similar issue here I think. In Robotium sample, NotePadTest, as soon as I add 
hamcrest-all-1.2.jar to the library references in Eclipse Project, I get 
multiple Dalvik errors, starting from:
#############
[2011-07-09 20:06:13 - NotePadTest] Dx warning: Ignoring InnerClasses attribute 
for an anonymous inner class
(org.hamcrest.generator.qdox.JavaDocBuilder$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
#############
and then on to:
#############
[2011-07-09 20:06:13 - NotePadTest] Dx 
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.code.SimException: local variable type mismatch: attempt to 
set or access a value of type java.lang.Object using a local variable of type 
int. This is symptomatic of .class transformation tools that ignore local 
variable information.
#############
down to:
#############
...while processing yylex ()I
...while processing org/hamcrest/generator/qdox/parser/impl/JFlexLexer.class
#############
Full console log attached.

Original comment by piscopo....@gmail.com on 9 Jul 2011 at 6:09

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by t.denley on 12 May 2012 at 10:38

GoogleCodeExporter commented 8 years ago
Firstly, you probably don't need the hamcrest-all.jar.  Try using just 
hamcrest-core and hamcrest-library.

The underlying cause looks to be a class in the packaged QDox codebase.  Before 
digging too much deeper, it is probably worth me updating hamcrest to use the 
latest version of QDox.  If I try this, is anyone able to re-try on android, as 
I don't have an appropriate dev environment available at the moment.

Original comment by t.denley on 12 May 2012 at 11:11

GoogleCodeExporter commented 8 years ago
As there don't appear to be any android developers around to test this, or 
gather more data, I'm closing for now.

Original comment by t.denley on 28 Jul 2012 at 10:13