Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javap/T7186925.java
32285 views
/*1* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.2* 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*/2223/*24* @test25* @bug 718692526* @summary JavapTask passes null to java.io.Writer27*/2829import java.io.*;30import java.util.*;31import javax.tools.*;32import com.sun.tools.javap.*;3334public class T718692535{36public static void main(String... args) {37new T7186925().run();38}3940void run() {41verify("java.lang.Object");42if (errors > 0)43throw new Error(errors + " found.");44}4546void verify(String className) {47try {48JavaFileManager fileManager = JavapFileManager.create(null, null);49JavaFileObject fo = fileManager.getJavaFileForInput(StandardLocation.PLATFORM_CLASS_PATH, className, JavaFileObject.Kind.CLASS);50if (fo == null) {51error("Can't find " + className);52} else {53JavapTask t = new JavapTask(null, fileManager, null);54t.handleOptions(new String[] { "-sysinfo", className });55JavapTask.ClassFileInfo cfInfo = t.read(fo);56expectEqual(cfInfo.cf.byteLength(), cfInfo.size);57}58} catch (NullPointerException ee) {59ee.printStackTrace();60error("Exception: " + ee);61} catch (Exception ee) {62System.err.println("Caught exception: " + ee);63}64}6566void expectEqual(int found, int expected) {67if (found != expected)68error("bad value found: " + found + " expected: " + expected);69}7071void error(String msg) {72System.err.println(msg);73errors++;74}7576int errors;77}787980