stringtemplate4 icon indicating copy to clipboard operation
stringtemplate4 copied to clipboard

Issue with template loading STGroupFile via URL

Open alexcase52 opened this issue 7 years ago • 1 comments

I have the URL to resource like jar:file://path/to/myjar.jar!/main/main.jar!/com/some/dao/Dao.sql.stg - I've got this using single jar app loader. I pass this URL to corresponding costructor of STGroupFile then internally in load() I see

loadGroupFile("", url.toString());

So url is converted to String via toString() and then internally in loadGroupFile result is passed to new URL(..):

URL f = new URL(fileName);
ANTLRInputStream fs = new ANTLRInputStream(f.openStream(), encoding);

In my case this new URL is of incorrect format and opening stream leads to an exception. I think the issue is in calling URL.toString() -> 'new URL()' instead of obtaining stream directrly from URL via

resource.openConnection().getInputStream()

Thanks

alexcase52 avatar Apr 25 '18 09:04 alexcase52

Hi @alexcase52 is this fixed by https://github.com/antlr/stringtemplate4/pull/207 ?

parrt avatar Nov 09 '18 00:11 parrt