Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/arm/go/src/cmd/fix/jnitype.go

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
	"go/ast"
)

func init() {
	register(jniFix)
}

var jniFix = fix{
	name:     "jni",
	date:     "2017-12-04",
	f:        jnifix,
	desc:     `Fixes initializers of JNI's jobject and subtypes`,
	disabled: false,
}

// Old state:
//   type jobject *_jobject
// New state:
//   type jobject uintptr
// and similar for subtypes of jobject.
// This fix finds nils initializing these types and replaces the nils with 0s.
func jnifix(f *ast.File) bool {
	return typefix(f, func(s string) bool {
		switch s {
		case "C.jobject":
			return true
		case "C.jclass":
			return true
		case "C.jthrowable":
			return true
		case "C.jstring":
			return true
		case "C.jarray":
			return true
		case "C.jbooleanArray":
			return true
		case "C.jbyteArray":
			return true
		case "C.jcharArray":
			return true
		case "C.jshortArray":
			return true
		case "C.jintArray":
			return true
		case "C.jlongArray":
			return true
		case "C.jfloatArray":
			return true
		case "C.jdoubleArray":
			return true
		case "C.jobjectArray":
			return true
		case "C.jweak":
			return true
		}
		return false
	})
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.