Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obsidianc crashes if the input file begins with a dot, or is not a valid Java class name in som way #287

Open
ishantheperson opened this issue Apr 21, 2020 · 0 comments

Comments

@ishantheperson
Copy link
Collaborator

Describe the bug
Currently the source file name is used when generated some of the class names, this causes crashes if it isn't a valid class name in Java.

To Reproduce

ishan@ishan-macbook ~ > cat .testing.obs
main contract Foo { }
ishan@ishan-macbook ~ > obsidianc .testing.obs
org/hyperledger/fabric/example/Contract.java
org/hyperledger/fabric/example/Foo.java
Exception in thread "main" java.lang.IllegalArgumentException: Part '' of the package name 'org.hyperledger.fabric.example..testingOuterClass' is invalid
	at com.helger.jcodemodel.JPackage.<init>(JPackage.java:194)
	at com.helger.jcodemodel.JCodeModel.lambda$_package$0(JCodeModel.java:226)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1133)
	at com.helger.jcodemodel.JCodeModel._package(JCodeModel.java:226)
	at com.helger.jcodemodel.JDirectClass._package(JDirectClass.java:122)
	at com.helger.jcodemodel.writer.JFormatter$NameUsage.isAmbiguousIn(JFormatter.java:127)
	at com.helger.jcodemodel.writer.JFormatter.writeClassFull(JFormatter.java:925)
	at com.helger.jcodemodel.writer.JCMWriter.buildPackage(JCMWriter.java:324)
	at com.helger.jcodemodel.writer.JCMWriter.build(JCMWriter.java:288)
	at com.helger.jcodemodel.writer.JCMWriter.build(JCMWriter.java:226)
	at com.helger.jcodemodel.writer.JCMWriter.build(JCMWriter.java:198)
	at com.helger.jcodemodel.writer.JCMWriter.build(JCMWriter.java:239)
	at edu.cmu.cs.obsidian.Main$.compileProgram(Main.scala:348)
	at edu.cmu.cs.obsidian.Main$.compileProgram(Main.scala:247)
	at edu.cmu.cs.obsidian.Main$.main(Main.scala:239)
	at edu.cmu.cs.obsidian.Main.main(Main.scala)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant