Debian Codegraph @

tests/reproducers/signed/Kemtrakpro/srcs/Kemtrak.java

raw symbols SCIP
1 /*
2 Copyright (C) 2017 Red Hat, Inc.
3
4 This file is part of IcedTea.
5
6 IcedTea is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, version 2.
9
10 IcedTea is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with IcedTea; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301 USA.
19
20 Linking this library statically or dynamically with other modules is
21 making a combined work based on this library. Thus, the terms and
22 conditions of the GNU General Public License cover the whole
23 combination.
24
25 As a special exception, the copyright holders of this library give you
26 permission to link this library with independent modules to produce an
27 executable, regardless of the license terms of these independent
28 modules, and to copy and distribute the resulting executable under
29 terms of your choice, provided that you also meet, for each linked
30 independent module, the terms and conditions of the license of that
31 module. An independent module is a module which is not derived from
32 or based on this library. If you modify this library, you may extend
33 this exception to your version of the library, but you are not
34 obligated to do so. If you do not wish to do so, delete this
35 exception statement from your version.
36 */
37
38 import java.applet.Applet;
39 import java.io.File;
40 import java.io.IOException;
41 import java.lang.reflect.*;
42 import java.net.JarURLConnection;
43 import java.net.MalformedURLException;
44 import java.net.URL;
45
46 public class Kemtrak extends Applet {
47
48 private class Killer extends Thread {
49
50 public int n = 1000;
51
52 @Override
53 public void run() {
54 try {
55 Thread.sleep(n);
56 System.out.println("Applet killing himself after " + n + " ms of life");
57 System.exit(0);
58 } catch (Exception ex) {
59 }
60 }
61 }
62 private Killer killer;
63
64 public static void main(String[] args) throws IOException {
65 System.out.println("Kemtrak2");
66 if (args.length == 2 && args[0].equals("closeJar")) {
67 String cbase = args[1];
68 System.out.println("Closing Jar!");
69 URL localURL = new java.net.URL("jar", "", cbase + "jcalendar.jar!/");
70 JarURLConnection localObject3 = (java.net.JarURLConnection) localURL.openConnection();
71 java.util.jar.JarFile localJarFile = ((java.net.JarURLConnection) localObject3).getJarFile();
72 String str9 = localJarFile.getName();
73 int i3 = localJarFile.size();
74 localJarFile.close();
75 System.out.println("jcalendar " + localURL + " " + str9 + ", entrie: " + i3);
76 //if one call inisde jcalendar.jar (jcalendar1() and/or jcalendar2) *BEFORE* closing, issue is NOT hit
77 jcalendar2();
78 } else {
79 jcalendar1();
80 }
81 System.out.println("kemtrak finished");
82 }
83
84 @Override
85 public void init() {
86 try {
87 System.out.println("Kemtrak1");
88 String cj = this.getParameter("closeJar");
89 if ("closeJar".equals(cj)) {
90 Kemtrak.main(new String[]{"closeJar", getCodeBase().toExternalForm()});
91 } else {
92 Kemtrak.main(new String[0]);
93 }
94 } catch (IOException u) {
95 throw new RuntimeException(u);
96 } finally {
97 killer = new Killer();
98 killer.start();
99 }
100 }
101
102
103 //we use reflection only to avoid jcalendar.jar on classpath
104
105 public static void jcalendar1() {
106 try {
107 Class<?> signedAppletClass = Class.forName("jcalendar");
108 Method m = signedAppletClass.getMethod("main1", String[].class);
109 m.invoke(null, (Object) null);
110 } catch (Exception e) {
111 throw new RuntimeException(e);
112 }
113 }
114
115 public static void jcalendar2() {
116 try {
117 Class<?> signedAppletClass = Class.forName("jcalendar");
118 Method m = signedAppletClass.getMethod("main2", String[].class);
119 m.invoke(null, (Object) null);
120 } catch (Exception e) {
121 throw new RuntimeException(e);
122 }
123 }
124
125 }