Category: Exams of Java

Introducing the Splay Tree data structure – Arrays, collections and data structuresIntroducing the Splay Tree data structure – Arrays, collections and data structures

120. Introducing the Splay Tree data structure A Splay Tree is a flavor of Binary Search Tree (BST). Its particularity consists of the fact that it is a self-balancing tree [...]

Serializing objects to byte arrays – Java I/O: Context-Specific Deserialization FiltersSerializing objects to byte arrays – Java I/O: Context-Specific Deserialization Filters

124. Serializing objects to byte arrays In chapter 4, Problem X, we talked about the serialization/deserialization of Java records, so you should be pretty familiar with these operations. In a [...]

Serializing objects to XML – Java I/O: Context-Specific Deserialization FiltersSerializing objects to XML – Java I/O: Context-Specific Deserialization Filters

126. Serializing objects to XML Serializing/deserializing objects to XML via the JDK API can be accomplished via java.beans.XMLEncoder, respectively XMLDecoder. The XMLEncoder API relies on Java Reflection to discover the [...]

Introducing JDK 9 deserialization filter – Java I/O: Context-Specific Deserialization FiltersIntroducing JDK 9 deserialization filter – Java I/O: Context-Specific Deserialization Filters

127. Introducing JDK 9 deserialization filter As you know from Chapter 4, Problem X, deserialization is exposed to vulnerabilities that may cause serious security issues. In other words, between a [...]

Implementing a custom pattern-based ObjectInputFilter – Java I/O: Context-Specific Deserialization FiltersImplementing a custom pattern-based ObjectInputFilter – Java I/O: Context-Specific Deserialization Filters

128. Implementing a custom pattern-based ObjectInputFilter Let’s assume that we already have the Melon class and the helper methods for serializing/deserializing objects to/from byte arrays from Problem 124.Creating a pattern-based [...]

Avoiding StackOverflowError at deserialization – Java I/O: Context-Specific Deserialization FiltersAvoiding StackOverflowError at deserialization – Java I/O: Context-Specific Deserialization Filters

132. Avoiding StackOverflowError at deserialization Let’s consider the following snippet of code: // ‘mapOfSets’ is the object to serialize/deserializeHashMap<Set, Integer> mapOfSets = new HashMap<>();Set<Set> set = new HashSet<>();mapOfSets.put(set, 1);set.add(set); And, [...]

Introducing JDK 17 easy filter creation – Java I/O: Context-Specific Deserialization FiltersIntroducing JDK 17 easy filter creation – Java I/O: Context-Specific Deserialization Filters

134. Introducing JDK 17 easy filter creation Starting with JDK 17, we can express filters more intuitively and readable via two convenient methods named allowFilter() and rejectFilter(). And, since the [...]

Tackling context-specific deserialization filters – Java I/O: Context-Specific Deserialization FiltersTackling context-specific deserialization filters – Java I/O: Context-Specific Deserialization Filters

135. Tackling context-specific deserialization filters JDK 17 enriched the deserialization filter capabilities with the implementation of JEP 415, Context-Specific Deserialization Filters.Practically, JDK 17 added the so-called Filter Factories. Depending on [...]