I have a call to a HashMap's containsKey method that I expect to return true. It returns true if I compile my program to .class files and run it like that, but if I build a JAR then the same call returns false for reasons I cannot comprehend.
I've debugged both the .class and the JAR versions (the JAR using a remote connection as described in http://ift.tt/1KtRoe6 ) and in both cases the HashMap appears to contain the Key I'm trying to check.
The HashMap uses URI objects as keys. Here are the contents of the variables as shown in each debug session:
When run as a .class file
HashMap Key: java.net.URI = file:/E:/SSD%20App%20Libraries/Google%20Drive/Programming/Bet%20Matching/Java%20Sim/target/classes/simfiles/paytables/
URIToCheck: java.net.URI = file:///E:/SSD%20App%20Libraries/Google%20Drive/Programming/Bet%20Matching/Java%20Sim/target/classes/simfiles/paytables/
Result: GameTreeItemsMap.containsKey(URIToCheck) is true
When run as a JAR
HashMap Key: java.net.URI = jar:file:/E:/SSD%20App%20Libraries/Google%20Drive/Programming/Bet%20Matching/Java%20Sim/out/artifacts/JavaSim_jar/Java%20Sim.jar!/simfiles/paytables/
URIToCheck: java.net.URI = jar:file:///E:/SSD%2520App%2520Libraries/Google%2520Drive/Programming/Bet%2520Matching/Java%2520Sim/out/artifacts/JavaSim_jar/Java%2520Sim.jar!/simfiles/paytables/
Result: GameTreeItemsMap.containsKey(URIToCheck) is false
I would expect the method to return true in both cases. Do URIs somehow behave differently inside a JAR? What's going on?
Thanks in advance for any help!
Aucun commentaire:
Enregistrer un commentaire