...

Source file src/cmd/fix/jnitype.go

     1	// Copyright 2017 The Go Authors. All rights reserved.
     2	// Use of this source code is governed by a BSD-style
     3	// license that can be found in the LICENSE file.
     4	
     5	package main
     6	
     7	import (
     8		"go/ast"
     9	)
    10	
    11	func init() {
    12		register(jniFix)
    13	}
    14	
    15	var jniFix = fix{
    16		name:     "jni",
    17		date:     "2017-12-04",
    18		f:        jnifix,
    19		desc:     `Fixes initializers of JNI's jobject and subtypes`,
    20		disabled: false,
    21	}
    22	
    23	// Old state:
    24	//   type jobject *_jobject
    25	// New state:
    26	//   type jobject uintptr
    27	// and similar for subtypes of jobject.
    28	// This fix finds nils initializing these types and replaces the nils with 0s.
    29	func jnifix(f *ast.File) bool {
    30		return typefix(f, func(s string) bool {
    31			switch s {
    32			case "C.jobject":
    33				return true
    34			case "C.jclass":
    35				return true
    36			case "C.jthrowable":
    37				return true
    38			case "C.jstring":
    39				return true
    40			case "C.jarray":
    41				return true
    42			case "C.jbooleanArray":
    43				return true
    44			case "C.jbyteArray":
    45				return true
    46			case "C.jcharArray":
    47				return true
    48			case "C.jshortArray":
    49				return true
    50			case "C.jintArray":
    51				return true
    52			case "C.jlongArray":
    53				return true
    54			case "C.jfloatArray":
    55				return true
    56			case "C.jdoubleArray":
    57				return true
    58			case "C.jobjectArray":
    59				return true
    60			case "C.jweak":
    61				return true
    62			}
    63			return false
    64		})
    65	}
    66	

View as plain text