When specified, no service clients will be generated. We only support
service clients in the Kotlin generator, so this is implicitly a
Kotlin-only option, but it's not prefixed with `kt` because it could
apply to Java in the future.
This is useful for projects that only need Thrift-generated structures,
etc. and won't use Thrift service calls.
LoadFailedException wraps a list of error reports. In the load path,
these reports are primarily added by the parser, but we also construct
LoadFailedException objects to wrap FileNotFoundException instances.
The compiler previously only printed the formatted reports. Other
wrapped exception causes were effectively swallowed which lead to
ambiguous compilation failures when an included .thrift file couldn't be
loaded, for example.
This change prints the underlying cause when the LoadFailedException
doesn't have any error reports. This feels like a good compromise that
addresses the root problem of certain exception cases being swallowed.
Alternatively, we could avoid wrapping FileNotFoundException and let is
bubble up on its own, but that would be a change from the currently
documented "contract" where we except all load errors to be represented
by LoadFailedException.
* Use openjdk instead of oracle jdk
* Don't force Java 8 compatibility in the compiler
* Remove generated annotations from apache thrift classes
* Remove ErrorProne
This adds support in generated Kotlin code for unions that have default values.
Unions are currently represented as sealed types; the default value, if present, will be a static val on the base sealed type. For example, given the following thrift:
```
union Sample {
1: string Foo = "bar";
}
```
this will emit (partial code):
```
sealed class Sample : Struct {
companion object {
@JvmStatic
val DEFAULT: Sample = Foo("bar")
}
...
class Builder {
private var value: Sample? = DEFAULT
...
}
...
class Adapter {
override fun read(protocol: Protocol): Sample {
var result: Sample = DEFAULT
...
}
}
}
```
The only point about which I'm uncertain is the Adapter.read method; it's not clear to me whether we should assume a default value if no value (or no expected value) is received; the remote end may have a different idea about what the default value is. I expect we'll never revisit this point due to the obscurity of the feature, but have called out the question as a TODO.
Fixes#303.
Instead of using error nodes in `ThriftListener`, we can get better (and prefabricated) error messages directly from ANTLR using their ANTLRErrorListener interface. As a side effect, we can also prevent antlr from spamming stderr!
Fixes#298
Prior to this commit, our generated antlr parser would happily stop midway through a file if it discovered a token it couldn't handle, such as a semicolon at the top level. This was treated as a successful parse, leading to surprising cases of missing generated structs.
Fixed here by adding `EOF` to the end of our top-level `document` definition, which is the antlr way of saying "consume all input or else it is an error".
Fixes#297
These have always been documented (incorrectly) to return null if no matching member is found. They've always actually thrown NoSuchElementExceptions. This commit changes the documentation to reflect that.
Also, change the representation of an empty union from an empty sealed class (which can never be instantiated) to a plain-old empty class.
TODO: toString for empty union, toString for sealed class leaf-nodes.
Fixes#285
Version 2.x of the shadow plugin had an initialization bug causing warnings about use of deprecated Gradle features; the workaround was to specify `mainClassName` _prior_ to applying the plugin. Happily, the 4.x release of the plugin fixes the bug.