Merge "v.io/x/ref/lib/vd/codegen/java: don't use "final" for Java local variables"
diff --git a/lib/vdl/codegen/java/file_array.go b/lib/vdl/codegen/java/file_array.go
index 9e069c3..633e8a1 100644
--- a/lib/vdl/codegen/java/file_array.go
+++ b/lib/vdl/codegen/java/file_array.go
@@ -57,7 +57,7 @@
}
private static {{ .ElemType }}[] convert({{ .ElemPrimitiveType }}[] arr) {
- final {{ .ElemType }}[] ret = new {{ .ElemType }}[arr.length];
+ {{ .ElemType }}[] ret = new {{ .ElemType }}[arr.length];
for (int i = 0; i < arr.length; ++i) {
ret[i] = arr[i];
}
diff --git a/lib/vdl/codegen/java/file_client_factory.go b/lib/vdl/codegen/java/file_client_factory.go
index b16bf38..3de8a5f 100644
--- a/lib/vdl/codegen/java/file_client_factory.go
+++ b/lib/vdl/codegen/java/file_client_factory.go
@@ -25,7 +25,7 @@
*
* @param name name to bind to
*/
- public static {{ .ServiceName }}Client get{{ .ServiceName }}Client(final java.lang.String name) {
+ public static {{ .ServiceName }}Client get{{ .ServiceName }}Client(java.lang.String name) {
return get{{ .ServiceName }}Client(name, null);
}
@@ -35,11 +35,11 @@
* <p><ul>
* <li>{@link io.v.v23.OptionDefs#CLIENT}, which specifies a {@link io.v.v23.rpc.Client} to use for all rpc calls.</li>
* </ul>
- *
+ *
* @param name name to bind to
* @param opts creation options
*/
- public static {{ .ServiceName }}Client get{{ .ServiceName }}Client(final java.lang.String name, final io.v.v23.Options opts) {
+ public static {{ .ServiceName }}Client get{{ .ServiceName }}Client(java.lang.String name, io.v.v23.Options opts) {
io.v.v23.rpc.Client client = null;
if (opts != null && opts.get(io.v.v23.OptionDefs.CLIENT) != null) {
client = opts.get(io.v.v23.OptionDefs.CLIENT, io.v.v23.rpc.Client.class);
diff --git a/lib/vdl/codegen/java/file_client_impl.go b/lib/vdl/codegen/java/file_client_impl.go
index 7b845f9..36b5e20 100644
--- a/lib/vdl/codegen/java/file_client_impl.go
+++ b/lib/vdl/codegen/java/file_client_impl.go
@@ -37,7 +37,7 @@
* @param client Vanadium client
* @param vName remote server name
*/
- public {{ .ServiceName }}ClientImpl(final io.v.v23.rpc.Client client, final java.lang.String vName) {
+ public {{ .ServiceName }}ClientImpl(io.v.v23.rpc.Client client, java.lang.String vName) {
this.client = client;
this.vName = vName;
{{/* Initialize the embeded impls */}}
@@ -60,16 +60,16 @@
{{ range $method := .Methods }}
{{/* The optionless overload simply calls the overload with options */}}
@Override
- public {{ $method.RetType }} {{ $method.Name }}(final io.v.v23.context.VContext context{{ $method.DeclarationArgs }}) throws io.v.v23.verror.VException {
+ public {{ $method.RetType }} {{ $method.Name }}(io.v.v23.context.VContext context{{ $method.DeclarationArgs }}) throws io.v.v23.verror.VException {
{{if $method.Returns }}return{{ end }} {{ $method.Name }}(context{{ $method.CallingArgsLeadingComma }}, null);
}
{{/* The main client impl method body */}}
@Override
- public {{ $method.RetType }} {{ $method.Name }}(final io.v.v23.context.VContext context{{ $method.DeclarationArgs }}, io.v.v23.Options vOpts) throws io.v.v23.verror.VException {
+ public {{ $method.RetType }} {{ $method.Name }}(io.v.v23.context.VContext context{{ $method.DeclarationArgs }}, io.v.v23.Options vOpts) throws io.v.v23.verror.VException {
{{/* Start the vanadium call */}}
// Start the call.
- final java.lang.Object[] _args = new java.lang.Object[]{ {{ $method.CallingArgs }} };
- final java.lang.reflect.Type[] _argTypes = new java.lang.reflect.Type[]{ {{ $method.CallingArgTypes }} };
+ java.lang.Object[] _args = new java.lang.Object[]{ {{ $method.CallingArgs }} };
+ java.lang.reflect.Type[] _argTypes = new java.lang.reflect.Type[]{ {{ $method.CallingArgTypes }} };
final io.v.v23.rpc.Client.Call _call = getClient(context).startCall(context, this.vName, "{{ $method.Name }}", _args, _argTypes, vOpts);
// Finish the call.
@@ -77,17 +77,17 @@
{{ if $method.NotStreaming }}
{{ if $method.IsVoid }}
- final java.lang.reflect.Type[] _resultTypes = new java.lang.reflect.Type[]{};
+ java.lang.reflect.Type[] _resultTypes = new java.lang.reflect.Type[]{};
_call.finish(_resultTypes);
{{ else }} {{/* else $method.IsVoid */}}
- final java.lang.reflect.Type[] _resultTypes = new java.lang.reflect.Type[]{
+ java.lang.reflect.Type[] _resultTypes = new java.lang.reflect.Type[]{
{{ range $outArg := $method.OutArgs }}
new com.google.common.reflect.TypeToken<{{ $outArg.Type }}>() {}.getType(),
{{ end }}
};
- final java.lang.Object[] _results = _call.finish(_resultTypes);
+ java.lang.Object[] _results = _call.finish(_resultTypes);
{{ if $method.MultipleReturn }}
- final {{ $method.DeclaredObjectRetType }} _ret = new {{ $method.DeclaredObjectRetType }}();
+ {{ $method.DeclaredObjectRetType }} _ret = new {{ $method.DeclaredObjectRetType }}();
{{ range $i, $outArg := $method.OutArgs }}
_ret.{{ $outArg.FieldName }} = ({{ $outArg.Type }})_results[{{ $i }}];
{{ end }} {{/* end range over outargs */}}
@@ -101,14 +101,14 @@
{{else }} {{/* else $method.NotStreaming */}}
return new io.v.v23.vdl.ClientStream<{{ $method.SendType }}, {{ $method.RecvType }}, {{ $method.DeclaredObjectRetType }}>() {
@Override
- public void send(final {{ $method.SendType }} item) throws io.v.v23.verror.VException {
- final java.lang.reflect.Type type = new com.google.common.reflect.TypeToken<{{ $method.SendType }}>() {}.getType();
+ public void send({{ $method.SendType }} item) throws io.v.v23.verror.VException {
+ java.lang.reflect.Type type = new com.google.common.reflect.TypeToken<{{ $method.SendType }}>() {}.getType();
_call.send(item, type);
}
@Override
public {{ $method.RecvType }} recv() throws java.io.EOFException, io.v.v23.verror.VException {
- final java.lang.reflect.Type type = new com.google.common.reflect.TypeToken<{{ $method.RecvType }}>() {}.getType();
- final java.lang.Object result = _call.recv(type);
+ java.lang.reflect.Type type = new com.google.common.reflect.TypeToken<{{ $method.RecvType }}>() {}.getType();
+ java.lang.Object result = _call.recv(type);
try {
return ({{ $method.RecvType }})result;
} catch (java.lang.ClassCastException e) {
@@ -118,11 +118,11 @@
@Override
public {{ $method.DeclaredObjectRetType }} finish() throws io.v.v23.verror.VException {
{{ if $method.IsVoid }}
- final java.lang.reflect.Type[] resultTypes = new java.lang.reflect.Type[]{};
+ java.lang.reflect.Type[] resultTypes = new java.lang.reflect.Type[]{};
_call.finish(resultTypes);
return null;
{{ else }} {{/* else $method.IsVoid */}}
- final java.lang.reflect.Type[] resultTypes = new java.lang.reflect.Type[]{
+ java.lang.reflect.Type[] resultTypes = new java.lang.reflect.Type[]{
new com.google.common.reflect.TypeToken<{{ $method.DeclaredObjectRetType }}>() {}.getType()
};
return ({{ $method.DeclaredObjectRetType }})_call.finish(resultTypes)[0];
@@ -136,12 +136,12 @@
{{/* Iterate over methods from embeded services and generate code to delegate the work */}}
{{ range $eMethod := .EmbedMethods }}
@Override
- public {{ $eMethod.RetType }} {{ $eMethod.Name }}(final io.v.v23.context.VContext context{{ $eMethod.DeclarationArgs }}) throws io.v.v23.verror.VException {
+ public {{ $eMethod.RetType }} {{ $eMethod.Name }}(io.v.v23.context.VContext context{{ $eMethod.DeclarationArgs }}) throws io.v.v23.verror.VException {
{{/* e.g. return this.implArith.cosine(context, [args]) */}}
{{ if $eMethod.Returns }}return{{ end }} this.impl{{ $eMethod.IfaceName }}.{{ $eMethod.Name }}(context{{ $eMethod.CallingArgsLeadingComma }});
}
@Override
- public {{ $eMethod.RetType }} {{ $eMethod.Name }}(final io.v.v23.context.VContext context{{ $eMethod.DeclarationArgs }}, io.v.v23.Options vOpts) throws io.v.v23.verror.VException {
+ public {{ $eMethod.RetType }} {{ $eMethod.Name }}(io.v.v23.context.VContext context{{ $eMethod.DeclarationArgs }}, io.v.v23.Options vOpts) throws io.v.v23.verror.VException {
{{/* e.g. return this.implArith.cosine(context, [args], options) */}}
{{ if $eMethod.Returns }}return{{ end }} this.impl{{ $eMethod.IfaceName }}.{{ $eMethod.Name }}(context{{ $eMethod.CallingArgsLeadingComma }}, vOpts);
}
diff --git a/lib/vdl/codegen/java/file_client_interface.go b/lib/vdl/codegen/java/file_client_interface.go
index 96c97f7..83ee6f1 100644
--- a/lib/vdl/codegen/java/file_client_interface.go
+++ b/lib/vdl/codegen/java/file_client_interface.go
@@ -36,8 +36,8 @@
{{/* Generate the method signature. */}}
{{ $method.Doc }}
- {{ $method.RetType }} {{ $method.Name }}(final io.v.v23.context.VContext context{{ $method.Args }}) throws io.v.v23.verror.VException;
- {{ $method.RetType }} {{ $method.Name }}(final io.v.v23.context.VContext context{{ $method.Args }}, final io.v.v23.Options vOpts) throws io.v.v23.verror.VException;
+ {{ $method.RetType }} {{ $method.Name }}(io.v.v23.context.VContext context{{ $method.Args }}) throws io.v.v23.verror.VException;
+ {{ $method.RetType }} {{ $method.Name }}(io.v.v23.context.VContext context{{ $method.Args }}, io.v.v23.Options vOpts) throws io.v.v23.verror.VException;
{{ end }}
}
`
diff --git a/lib/vdl/codegen/java/file_errors.go b/lib/vdl/codegen/java/file_errors.go
index 7c0272c..a9edffe 100644
--- a/lib/vdl/codegen/java/file_errors.go
+++ b/lib/vdl/codegen/java/file_errors.go
@@ -49,8 +49,8 @@
* Creates an error with the {@link #{{ $error.Name }}} identifier.
*/
{{ $error.AccessModifier }} static io.v.v23.verror.VException {{ $error.MethodName }}(io.v.v23.context.VContext _ctx{{ $error.MethodArgs}}) {
- final java.lang.Object[] _params = new java.lang.Object[] { {{ $error.Params }} };
- final java.lang.reflect.Type[] _paramTypes = new java.lang.reflect.Type[]{ {{ $error.ParamTypes }} };
+ java.lang.Object[] _params = new java.lang.Object[] { {{ $error.Params }} };
+ java.lang.reflect.Type[] _paramTypes = new java.lang.reflect.Type[]{ {{ $error.ParamTypes }} };
return new io.v.v23.verror.VException({{ $error.Name }}, _ctx, _paramTypes, _params);
}
{{ end }} {{/* range $file.Errors */}}
diff --git a/lib/vdl/codegen/java/file_server_interface.go b/lib/vdl/codegen/java/file_server_interface.go
index e4c7c7d..0b0d96c 100644
--- a/lib/vdl/codegen/java/file_server_interface.go
+++ b/lib/vdl/codegen/java/file_server_interface.go
@@ -39,7 +39,7 @@
{{/* Generate the method signature. */}}
{{ $method.Doc }}
- {{ $method.RetType }} {{ $method.Name }}(final io.v.v23.context.VContext ctx, final io.v.v23.rpc.ServerCall call{{ $method.Args }}) throws io.v.v23.verror.VException;
+ {{ $method.RetType }} {{ $method.Name }}(io.v.v23.context.VContext ctx, io.v.v23.rpc.ServerCall call{{ $method.Args }}) throws io.v.v23.verror.VException;
{{ end }}
}
`
diff --git a/lib/vdl/codegen/java/file_server_wrapper.go b/lib/vdl/codegen/java/file_server_wrapper.go
index 55faa59..cfca39c 100644
--- a/lib/vdl/codegen/java/file_server_wrapper.go
+++ b/lib/vdl/codegen/java/file_server_wrapper.go
@@ -37,7 +37,7 @@
*
* @param server server whose methods are to be invoked
*/
- public {{ .ServiceName }}ServerWrapper(final {{ .FullServiceName }}Server server) {
+ public {{ .ServiceName }}ServerWrapper({{ .FullServiceName }}Server server) {
this.server = server;
{{/* Initialize the embeded server wrappers */}}
{{ range $embed := .Embeds }}
@@ -86,7 +86,7 @@
* @param method method whose tags are to be returned
*/
@SuppressWarnings("unused")
- public io.v.v23.vdl.VdlValue[] getMethodTags(final java.lang.String method) throws io.v.v23.verror.VException {
+ public io.v.v23.vdl.VdlValue[] getMethodTags(java.lang.String method) throws io.v.v23.verror.VException {
{{ range $methodName, $tags := .MethodTags }}
if ("{{ $methodName }}".equals(method)) {
try {
@@ -100,7 +100,7 @@
{{ end }}
{{ range $embed := .Embeds }}
{
- final io.v.v23.vdl.VdlValue[] tags = this.wrapper{{ $embed.Name }}.getMethodTags(method);
+ io.v.v23.vdl.VdlValue[] tags = this.wrapper{{ $embed.Name }}.getMethodTags(method);
if (tags != null) {
return tags;
}
@@ -112,18 +112,18 @@
{{/* Iterate over methods defined directly in the body of this server */}}
{{ range $method := .Methods }}
{{ $method.JavaDoc }}
- public {{ $method.RetType }} {{ $method.Name }}(final io.v.v23.context.VContext ctx, final io.v.v23.rpc.StreamServerCall call{{ $method.DeclarationArgs }}) throws io.v.v23.verror.VException {
+ public {{ $method.RetType }} {{ $method.Name }}(io.v.v23.context.VContext ctx, final io.v.v23.rpc.StreamServerCall call{{ $method.DeclarationArgs }}) throws io.v.v23.verror.VException {
{{ if $method.IsStreaming }}
- final io.v.v23.vdl.Stream<{{ $method.SendType }}, {{ $method.RecvType }}> _stream = new io.v.v23.vdl.Stream<{{ $method.SendType }}, {{ $method.RecvType }}>() {
+ io.v.v23.vdl.Stream<{{ $method.SendType }}, {{ $method.RecvType }}> _stream = new io.v.v23.vdl.Stream<{{ $method.SendType }}, {{ $method.RecvType }}>() {
@Override
public void send({{ $method.SendType }} item) throws io.v.v23.verror.VException {
- final java.lang.reflect.Type type = new com.google.common.reflect.TypeToken< {{ $method.SendType }} >() {}.getType();
+ java.lang.reflect.Type type = new com.google.common.reflect.TypeToken< {{ $method.SendType }} >() {}.getType();
call.send(item, type);
}
@Override
public {{ $method.RecvType }} recv() throws java.io.EOFException, io.v.v23.verror.VException {
- final java.lang.reflect.Type type = new com.google.common.reflect.TypeToken< {{ $method.RecvType }} >() {}.getType();
- final java.lang.Object result = call.recv(type);
+ java.lang.reflect.Type type = new com.google.common.reflect.TypeToken< {{ $method.RecvType }} >() {}.getType();
+ java.lang.Object result = call.recv(type);
try {
return ({{ $method.RecvType }})result;
} catch (java.lang.ClassCastException e) {
@@ -139,7 +139,7 @@
{{/* Iterate over methods from embeded servers and generate code to delegate the work */}}
{{ range $eMethod := .EmbedMethods }}
{{ $eMethod.JavaDoc }}
- public {{ $eMethod.RetType }} {{ $eMethod.Name }}(final io.v.v23.context.VContext ctx, final io.v.v23.rpc.StreamServerCall call{{ $eMethod.DeclarationArgs }}) throws io.v.v23.verror.VException {
+ public {{ $eMethod.RetType }} {{ $eMethod.Name }}(io.v.v23.context.VContext ctx, io.v.v23.rpc.StreamServerCall call{{ $eMethod.DeclarationArgs }}) throws io.v.v23.verror.VException {
{{/* e.g. return this.stubArith.cosine(ctx, call, [args], options) */}}
{{ if $eMethod.Returns }}return{{ end }} this.wrapper{{ $eMethod.IfaceName }}.{{ $eMethod.Name }}(ctx, call{{ $eMethod.CallingArgs }});
}
diff --git a/lib/vdl/codegen/java/file_struct.go b/lib/vdl/codegen/java/file_struct.go
index 30bdf19..3c7190f 100644
--- a/lib/vdl/codegen/java/file_struct.go
+++ b/lib/vdl/codegen/java/file_struct.go
@@ -75,7 +75,7 @@
if (this == obj) return true;
if (obj == null) return false;
if (this.getClass() != obj.getClass()) return false;
- {{ if gt (len .Fields) 0 }} final {{.Name}} other = ({{.Name}})obj; {{ end }}
+ {{ if gt (len .Fields) 0 }} {{.Name}} other = ({{.Name}})obj; {{ end }}
{{ range $field := .Fields }}
{{ if .IsArray }}
@@ -104,7 +104,7 @@
@Override
public int hashCode() {
int result = 1;
- final int prime = 31;
+ int prime = 31;
{{ range $field := .Fields }}
result = prime * result + {{$field.HashcodeComputation}};
{{ end }}
@@ -148,7 +148,6 @@
buf.WriteString(", ")
}
fld := structType.Field(i)
- buf.WriteString("final ")
buf.WriteString(javaType(fld.Type, false, env))
buf.WriteString(" ")
buf.WriteString(vdlutil.FirstRuneToLower(fld.Name))