Path: blob/master/test/jdk/tools/jlink/plugins/StripNativeDebugSymbolsPlugin/src/fib/FibJNI.java
41162 views
/*1* Copyright (c) 2019, Red Hat, Inc2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22package fib;23public class FibJNI {2425static {26// Native lib used for debug symbols stripping27System.loadLibrary("Fib");28}2930private final int num;31private final long expected;3233public FibJNI(int num, long expected) {34this.num = num;35this.expected = expected;36}3738public void callNative() {39callJNI(this, num);40}4142// Called from JNI library libFib43private void callback(long val) {44System.out.println("Debug: result was: " + val);45if (val != expected) {46throw new RuntimeException("Expected " + expected + " but got: " +val);47}48}4950public static native void callJNI(Object target, int num);5152public static void main(String[] args) {53if (args.length != 2) {54System.err.println("Usage: " + FibJNI.class.getName() + " <input> <expectedResult>");55}56int input = Integer.parseInt(args[0]);57long expected = Long.parseLong(args[1]);58FibJNI fib = new FibJNI(input, expected);59fib.callNative();60System.out.println("DEBUG: Sanity check for " + FibJNI.class.getSimpleName() + " passed.");61}62}636465