Created
November 9, 2018 09:33
-
-
Save metebalci/1bb53e8cbbbb664ff697a0a550f31606 to your computer and use it in GitHub Desktop.
JEP290
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.Serializable; | |
import java.io.ByteArrayOutputStream; | |
import java.io.ByteArrayInputStream; | |
import java.io.ObjectOutputStream; | |
import java.io.ObjectInputStream; | |
import java.io.ObjectInputFilter; | |
class JEP290 implements Serializable { | |
public static class Dummy implements Serializable { | |
} | |
public JEP290() { | |
} | |
public static void main(String[] args) throws Exception { | |
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
final ObjectOutputStream oos = new ObjectOutputStream(baos); | |
oos.writeObject(new JEP290()); | |
oos.writeObject(new Dummy()); | |
oos.close(); | |
final ObjectInputStream ois = new ObjectInputStream( | |
new ByteArrayInputStream( | |
baos.toByteArray())); | |
ois.setObjectInputFilter( | |
new ObjectInputFilter() { | |
public Status checkInput(FilterInfo filterInfo) { | |
if (filterInfo.serialClass() != JEP290.class ) { | |
return Status.REJECTED; | |
} else { | |
return Status.UNDECIDED; | |
} | |
} | |
}); | |
final Object jp1 = ois.readObject(); | |
final Object jn1 = ois.readObject(); | |
ois.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment