Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/security/BasicPermission/SerialVersion.java
41149 views
1
/*
2
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 4502729 7054918
27
* @summary BasicPermissionCollection serial version UID incorrect
28
*/
29
30
import java.security.*;
31
import java.io.*;
32
33
public class SerialVersion {
34
35
public static void main(String[] args) throws Exception {
36
String dir = System.getProperty("test.src");
37
File sFile = new File (dir,"SerialVersion.1.2.1");
38
// read in a 1.2.1 BasicPermissionCollection
39
try (FileInputStream fis = new FileInputStream(sFile);
40
ObjectInputStream ois = new ObjectInputStream(fis)) {
41
PermissionCollection pc = (PermissionCollection)ois.readObject();
42
System.out.println("1.2.1 collection = " + pc);
43
}
44
45
// read in a 1.3.1 BasicPermissionCollection
46
sFile = new File (dir,"SerialVersion.1.3.1");
47
48
try (FileInputStream fis = new FileInputStream(sFile);
49
ObjectInputStream ois = new ObjectInputStream(fis)) {
50
PermissionCollection pc = (PermissionCollection)ois.readObject();
51
System.out.println("1.3.1 collection = " + pc);
52
}
53
54
// read in a 1.4 BasicPermissionCollection
55
sFile = new File (dir,"SerialVersion.1.4");
56
try (FileInputStream fis = new FileInputStream(sFile);
57
ObjectInputStream ois = new ObjectInputStream(fis)) {
58
PermissionCollection pc = (PermissionCollection)ois.readObject();
59
System.out.println("1.4 collection = " + pc);
60
}
61
62
// write out current BasicPermissionCollection
63
MyPermission mp = new MyPermission("SerialVersionTest");
64
PermissionCollection bpc = mp.newPermissionCollection();
65
sFile = new File (dir,"SerialVersion.current");
66
try (FileOutputStream fos = new FileOutputStream("SerialVersion.current");
67
ObjectOutputStream oos = new ObjectOutputStream(fos)) {
68
oos.writeObject(bpc);
69
}
70
71
// read in current BasicPermissionCollection
72
try (FileInputStream fis = new FileInputStream("SerialVersion.current");
73
ObjectInputStream ois = new ObjectInputStream(fis)) {
74
PermissionCollection pc = (PermissionCollection)ois.readObject();
75
System.out.println("current collection = " + pc);
76
}
77
}
78
}
79
80
class MyPermission extends BasicPermission {
81
public MyPermission(String name) {
82
super(name);
83
}
84
}
85
86