/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4214888
* @clean CheckModifiers TestClass1 TestClass2
* @build CheckModifiers
* @run main CheckModifiers
* @summary Make sure that serialpersistentFields data member is used to
* represent tyhe serializable fields only if it has the modfiers
* static, final, private and the type is ObjectStreamField.
* No need to check for static, as ObjectStreamField class is not
* serializable.
*
*/
// Missing the "final" modifier
};
double field2;
int field3;
}
throws IOException, ClassNotFoundException {
/* These fields must be present in the stream */
try {
} catch(IllegalArgumentException e) {
throw new Error("data field: field3 not in the persistent stream");
}
try {
} catch(IllegalArgumentException e) {
throw new Error("data field: field4 not in the persistent stream");
}
}
};
// public instead of private
};
double field2;
int field3;
}
throws IOException, ClassNotFoundException {
/* These fields must be present in the stream */
try {
} catch(IllegalArgumentException e) {
throw new Error("data field: field3 not in the persistent stream");
}
try {
} catch(IllegalArgumentException e) {
throw new Error("data field: field4 not in the persistent stream");
}
}
};
// Not of type ObjectStreamField
double field2;
int field3;
}
throws IOException, ClassNotFoundException {
try {
} catch(IllegalArgumentException e) {
throw new Error("non-static field: " +
"serialPersistentFields must be in the persistent stream");
}
}
};
// Correct format
};
double field2;
int field3;
}
throws IOException, ClassNotFoundException {
try {
throw new Error("data field: field3 in the persistent stream");
} catch(IllegalArgumentException e) {
}
try {
throw new Error("data field: field4 in the persistent stream");
} catch(IllegalArgumentException e) {
}
}
};
public class CheckModifiers {
throws ClassNotFoundException, IOException{
new String("Test modifiers of serialPersistentFields"));
new String("Test modifiers of serialPersistentFields"));
new String("Test Type of serialPersistentFields"));
new String("Test modifiers of serialPersistentFields"));
try {
} finally {
}
try {
ois.readObject();
ois.readObject();
ois.readObject();
ois.readObject();
} finally {
}
}
};