opalj / opal

https://www.opal-project.de
Other
51 stars 27 forks source link

Escape spaces in jar/zip paths to avoid URISyntaxException #234

Closed errt closed 1 week ago

errt commented 1 week ago

Fixes #233

johannesduesing commented 1 week ago

I tried to reproduce this by executing:

[IJ]project Demos
[info] set current project to Demos (in build file:/C:/Users/Johannes/Documents/research/repos/opal/)
[IJ]run
[info] compiling 1 Scala source to C:\Users\Johannes\Documents\research\repos\opal\OPAL\bi\target\scala-2.13\classes ...
[info] done compiling

Multiple main classes detected. Select one to run:
 [1] org.opalj.ai.CipherGetInstanceStringUsage
 [..]
 [67] org.opalj.tac.fpcf.analyses.taint.ForwardClassForNameAnalysisRunnerIFDS

Enter number: 48
[info] running (fork) org.opalj.fpcf.analyses.FieldAccessInformationAnalysisDemo
[...]

Loading the class files now works - so the issue seems fixed - but i don't know if the demo is working as intended. I get a lot of the following ( i think for every class):

[info] [warn][project configuration] de.tud.cs.st.bat.resolved.analyses.bugs.InnerSerializableClass$SomeInnerClass is defined by multiple class files:
[info] [warn][project configuration]    jar:file:/C:/Users/Johannes/Documents/research/repos/opal/DEVELOPING_OPAL/demos/src/main/resources/bugs.zip!/BAT-Demo%20(Scala)/classes/de/tud/cs/st/bat/resolved/analyses/bugs/InnerSerializableClass$SomeInnerClass.class and
[info] [warn][project configuration]    jar:file:/C:/Users/Johannes/Documents/research/repos/opal/DEVELOPING_OPAL/demos/target/scala-2.13/classes/bugs.zip!/BAT-Demo%20(Scala)/classes/de/tud/cs/st/bat/resolved/analyses/bugs/InnerSerializableClass$SomeInnerClass.class
[info] [warn][project configuration]    keeping the first one.

and it finally fails with the following error:

[error] Exception in thread "main" java.lang.ClassCastException: class org.opalj.br.VirtualDeclaredField cannot be cast to class org.opalj.br.DefinedField (org.opalj.br.VirtualDeclaredField and org.opalj.br.DefinedField are in unnamed module of loader 'app')
[error]         at org.opalj.fpcf.analyses.FieldAccessInformationAnalysisDemo$.$anonfun$analyze$8(FieldAccessInformationAnalysisDemo.scala:101)
[error]         at org.opalj.fpcf.analyses.FieldAccessInformationAnalysisDemo$.$anonfun$analyze$8$adapted(FieldAccessInformationAnalysisDemo.scala:100)
[error]         at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
[error]         at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
[error]         at scala.collection.mutable.Growable.addAll(Growable.scala:61)
[error]         at scala.collection.mutable.Growable.addAll$(Growable.scala:57)
[error]         at scala.collection.immutable.SetBuilderImpl.addAll(Set.scala:396)
[error]         at scala.collection.immutable.Set$.from(Set.scala:353)
[error]         at scala.collection.IterableOnceOps.toSet(IterableOnce.scala:1322)
[error]         at scala.collection.IterableOnceOps.toSet$(IterableOnce.scala:1322)
[error]         at scala.collection.AbstractIterator.toSet(Iterator.scala:1300)
[error]         at org.opalj.fpcf.analyses.FieldAccessInformationAnalysisDemo$.analyze(FieldAccessInformationAnalysisDemo.scala:104)
[error]         at org.opalj.fpcf.analyses.FieldAccessInformationAnalysisDemo$.doAnalyze(FieldAccessInformationAnalysisDemo.scala:64)
[error]         at org.opalj.fpcf.analyses.FieldAccessInformationAnalysisDemo$.doAnalyze(FieldAccessInformationAnalysisDemo.scala:36)
[error]         at org.opalj.br.analyses.OneStepAnalysis.analyze(OneStepAnalysis.scala:30)
[error]         at org.opalj.br.analyses.OneStepAnalysis.analyze$(OneStepAnalysis.scala:21)
[error]         at org.opalj.br.analyses.ProjectAnalysisApplication.analyze(ProjectAnalysisApplication.scala:16)
[error]         at org.opalj.br.analyses.AnalysisApplication.main(AnalysisApplication.scala:227)
[error]         at org.opalj.br.analyses.AnalysisApplication.main$(AnalysisApplication.scala:101)
[error]         at org.opalj.br.analyses.ProjectAnalysisApplication.main(ProjectAnalysisApplication.scala:16)
[error]         at org.opalj.fpcf.analyses.FieldAccessInformationAnalysisDemo.main(FieldAccessInformationAnalysisDemo.scala)
[error] Nonzero exit code returned from runner: 1

@errt can you reproduce this?

Edit: Here's the log file: demo-48-sbt.txt

errt commented 1 week ago

Yes, I can reproduce it, it has been reported in #236 already. I have not found time to debug into it yet, though. It is a different issue though.

The warnings come from the fact that your analyzed class path contains the same file twice, so they are to be expected.