antlr / antlr/stringtemplate4

Issue with template loading STGroupFile via URL

Open
#200 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.