If you are not sure if the website you would like to visit is secure, you can verify it here. Enter the website address of the page and see parts of its content and the thumbnail images on this site. None (if any) dangerous scripts on the referenced page will be executed. Additionally, if the selected site contains subpages, you can verify it (review) in batches containing 5 pages.
favicon.ico: nipafx.dev/serialize-java-optional - Serialize Optional // nipafx.

site address: nipafx.dev/serialize-java-optional redirected to: nipafx.dev/serialize-java-optional

site title: Serialize Optional // nipafx

Our opinion (on Monday 14 September 2026 15:59:26 UTC):

GREEN status (no comments) - no comments
After content analysis of this website we propose the following hashtags:


Hashtags existing on this website:



page from cache: 13 minutes ago
Meta tags:
description=A summary of why you can t serialize Optional and what can be done to deal with that limitation if necessary.;
keywords=serialize optional;

Headings (most frequently used words):

optional, serialize, serializing, value, an, or, return, disclaimer, when, to, serializable, reflection, argument, field, wrapping, serialization, methods, with, arguments, fields, of, type, the, extracted, using, serializableoptional,

Text of the page (most frequently used words):
#optional (92), the (81), java (41), serialize (26), and (24), this (24), serializable (23), #serializableoptional (22), value (22), can (18), which (18), serialization (17), class (16), project (16), that (15), for (15), with (15), return (13), field (13), code (12), type (11), public (10), proxy (9), serializing (9), have (8), method (8), use (8), pattern (8), argument (8), post (8), has (7), static (7), methods (7), only (6), wrap (6), unwrap (6), when (6), using (6), empty (6), see (6), disclaimer (6), demo (5), arguments (5), its (5), could (5), reflection (5), more (5), private (5), null (5), there (5), how (5), but (5), cases (5), wrapping (5), one (5), you (5), junit (5), license (4), used (4), two (4), representation (4), fromoptional (4), serializationproxy (4), then (4), case (4), these (4), let (4), creates (4), want (4), why (4), your (4), community (4), without (3), from (3), what (3), about (3), logical (3), contains (3), are (3), final (3), implements (3), instance (3), done (3), link (3), contained (3), extracted (3), approach (3), fields (3), asoptional (3), string (3), int (3), all (3), instead (3), would (3), works (3), usability (3), specified (3), equivalent (3), object (3), created (3), out (3), features (3), most (3), should (3), part (3), not (3), design (3), isn (3), will (3), remi (3), look (3), possible (3), various (3), performance (3), scenarios (3), next (3), libfx (3), follow (3), share (3), blog (3), posts (3), series (3), pioneer (3), demos (3), streams (3), core (3), clean (3), privacy (2), rss (2), stackoverflow (2), github (2), twitch (2), youtube (2), discord (2), mastodon (2), bluesky (2), any (2), main (2), reasons (2), needs (2), serialized (2), called (2), wants (2), either (2), write (2), byte (2), makes (2), whether (2), usual (2), transform (2), transformforserializationproxy (2), optionalvalue (2), classusingoptional (2), classusingoptionalcorrectly (2), simply (2), wrapped (2), recommended (2), searchresult (2), log (2), often (2), search (2), void (2), variable (2), rmi (2), require (2), calls (2), like (2), different (2), ofnullable (2), must (2), make (2), little (2), exists (2), even (2), fact (2), nullable (2), likely (2), after (2), does (2), better (2), good (2), idea (2), implement (2), openjdk (2), first (2), other (2), explained (2), both (2), wrapper (2), really (2), active (2), platforms (2), watch (2), space (2), get (2), notified (2), publish (2), new (2), content (2), play (2), around (2), yourself (2), check (2), repository (2), many (2), snippets (2), shown (2), permissive (2), reuse (2), projects (2), showing (2), instances (2), give (2), insight (2), into (2), misunderstood (2), misused (2), intention (2), revealing (2), talks (2), record (2), args (2), var (2), turn (2), year (2), tools (2), techniques (2), switch (2), records (2), valhalla (2), panama (2), loom (2), leyden (2), amber (2), patterns (2), matching (2), ramp (2), migration (2), meta (2), maven (2), libraries (2), lambda (2), javafx (2), basics (2), j_ms (2), generics (2), dop (2), documentation (2), deprecation (2), libs (2), collections (2), architecture (2), tags (2), javascript (2), contact, imprint, helper, domain, legal, limitations, seen, immediately, extract, stream, difference, extracting, readability, clearer, costs, increased, size, time, didn, benchmark, tell, important, guess, depends, alternatively, orelse, constructor, assigns, possibilities, item, import, returned, callmethods, note, local, needed, shows, quickly, their, types, likes, course, adds, another, layer, indirection, leads, additional, situations, uses, consists, non, wraps, construction, less, verbose, equivalents, same, name, returns, was, where, always, extends, left, brevity, offers, values, declaring, carefully, decided, transient, recreated, deserialization, sense, need, actively, looked, apparently, order, convey, cover, customize, mechanism, actually, define, custom, form, chapter, bloch, excellent, 2nd, edition, effective, much, architectural, experience, remote, mailing, list, forax, describes, downsides, having, client, act, upon, exchange, regarding, explanation, request, clarification, initial, statement, reason, simple, just, allows, writing, reading, implemented, such, further, below, create, duplicates, functionality, full, replacement, lead, permeating, base, official, face, future, changes, language, don, think, might, optimize, follows, defined, rigid, structure, achieved, changing, signature, interface, several, approaches, exist, closer, send, over, wire, based, framework, rpc, least, restate, facts, prevents, creating, subclass, take, present, way, release, contain, finally, bringing, together, solutions, still, come, close, recent, toc, src, ser, table, contents, source, summary, deal, limitation, necessary, 2014, slides, upcoming, past, schedule, recordings, virtual, threads, vector, structured, concurrency, lilliput, galahad, babylon, conversation, book, club, videos, jms, newsletter, testing, rant, jigsaw, jdeps, impulse, default, lang, review, comments, words, site, well, enabled, nipafx,


Text of the page (random words):
serialize optional nipafx this site works well without javascript but it works even better with javascript enabled bluesky mastodon discord youtube twitch github stackoverflow rss words tags architecture clean code clean comments code review collections community core lang core libs default methods deprecation documentation dop generics impulse j_ms java 10 java 11 java 12 java 13 java 16 java 17 java 18 java 20 java 23 java 24 java 25 java 26 java 27 java 8 java 9 java basics java next javafx jdeps js junit 5 junit pioneer lambda libfx libraries maven meta migration on ramp optional pattern matching patterns performance project amber project jigsaw project leyden project loom project panama project valhalla rant record args records reflection serialization streams switch techniques testing tools turn of the year var blog posts newsletter the jms videos tags ai architecture book club clean code collections community conversation core libs deprecation documentation dop generics j_ms java 10 java 11 java 12 java 16 java 17 java 18 java 19 java 21 java 22 java 23 java 24 java 25 java 26 java 27 java 28 java 8 java 9 java basics java next javafx junit 5 junit pioneer lambda libraries maven meta migration on ramp openjdk optional pattern matching patterns performance project amber project babylon project galahad project leyden project lilliput project loom project panama project valhalla records reflection serialization streams structured concurrency switch techniques tools turn of the year var vector virtual threads recordings streams schedule code demos demos demos junit pioneer record args libfx talks my talks past upcoming slides about about me license privacy 2014 11 02 serialize optional post java 8 optional serialization a summary of why you can t serialize optional and what can be done to deal with that limitation if necessary serialize optional series this post is part of a series intention revealing code with optional the design of optional why isn t optional serializable serialize optional this one these posts give you more insight into one of java s more misunderstood and misused features source code want to play around with the code yourself check out the repository serialize optional a demo showing how to use the serialization proxy pattern to serialize optional instances it contains many of the snippets shown in this blog post it has a permissive license so you can reuse the code for your projects table of contents when to serialize optional serializing an optional argument or return value disclaimer serializing an optional field disclaimer serializable optional wrapping serialization serialize optional methods with optional arguments or return value fields of type optional serializing the extracted value using serializableoptional reflection share follow share this post with your community i m active on various platforms watch this space or follow me there to get notified when i publish new content ser this post is part of a series intention revealing code with optional the design of optional why isn t optional serializable serialize optional this one these posts give you more insight into one of java s more misunderstood and misused features src want to play around with the code yourself check out the repository serialize optional a demo showing how to use the serialization proxy pattern to serialize optional instances it contains many of the snippets shown in this blog post it has a permissive license so you can reuse the code for your projects toc when to serialize optional serializing an optional argument or return value disclaimer serializing an optional field disclaimer serializable optional wrapping serialization serialize optional methods with optional arguments or return value fields of type optional serializing the extracted value using serializableoptional reflection s f share this post with your community i m active on various platforms watch this space or follow me there to get notified when i publish new content in a recent post i explained why we can t serialize optional but what if after all that we still really really want to let s see how to come as close as possible we ll first take a look at possible scenarios in which we want to serialize optional and then present a serializable wrapper for it by the way the next release of libfx will contain that wrapper finally bringing both together we ll see solutions for the different scenarios when to serialize optional do restate the facts optional does not implement serializable and it is final which prevents us from creating a serializable subclass there are at least two scenarios which require to serialize an optional it could be an argument or return type of a method which is send over the wire with a serialization based rpc framework like rmi it could be a field in a serializable class let s have a closer look at both cases serializing an optional argument or return value in this case the argument or return type has to be serializable this can only be achieved by changing the method s signature and use a class which implements that interface several approaches exist it would be possible to simply create a class which duplicates all the functionality of optional but is serializable it can then be used as a full replacement this will likely lead to this class permeating the code base instead of the official one in the face of future changes to the language which might optimize performance if optional follows a defined and rigid structure and for various other reasons i don t think this is a good idea instead a simple class could be created which just allows to wrap and unwrap an optional it would be serializable by writing reading the object contained in that optional i implemented such a class in my demo project it is called serializableoptional and explained further below but let s first look at the other reason to serialize optional disclaimer i do not have much architectural experience with remote calls on the openjdk mailing list remi forax describes downsides of having the client act upon an empty optional for the exchange regarding that see remi s initial statement this request for clarification and remi s explanation serializing an optional field if a class wants to serialize a field of type optional it has to customize its serialization mechanism this is actually a good idea for any serializable see chapter 11 in java bloch s excellent effective java 2nd edition it can either define a custom serialized form or implement the serialization proxy pattern as it is the recommended approach in most cases i will only cover the proxy pattern disclaimer in most cases there is no need to have a nullable optional field in a class a better design can often be created and should be actively looked for apparently optional isn t serializable in order to convey that fact if the class must have an optional field it should be carefully decided whether it is part of the class s logical representation the fact that it is nullable optional makes it likely that it is transient and can be recreated after deserialization only if that is not the case does it make sense to serialize the field serializable optional the serializableoptional t link only exists to wrap and unwrap an optional and offers little of its features in the case of arguments or return values it can and in most cases should be used without even declaring a variable of type serializableoptional wrapping the class has two methods to wrap and unwrap an optional where t always extends serializable left out for brevity creates a serializable optional from the specified optional public static t serializableoptional t fromoptional optional t optional returns the optional instance with which this instance was created public optional t asoptional to make construction a little less verbose if no optional exists it has these equivalents of optional s methods with the same name usability method which creates a serializable optional which wraps an empty optional equivalent to optional empty public static t serializableoptional t empty usability method which creates a serializable optional for the specified value by wrapping it in an optional the value must be non null equivalent to optional of object public static t serializableoptional t of t value usability method which creates a serializable optional for the specified value by wrapping it in an optional the value can be null equivalent to optional ofnullable object public static t serializableoptional t ofnullable t value serialization serializableoptional uses the serialization proxy pattern its logical representation only consists of the value contained in the wrapped optional or null if it is empty serialization then works as usual see the demo for different use cases serialize optional let s see how to approach the situations in which we would like to serialize an argument return value or field of type optional methods with optional arguments or return value a method which likes to have an argument or return value of type optional but needs it to be serializable can use serializableoptional instead using it of course adds another layer of indirection which leads to additional calls these methods require all of their argument and return types to be serializable e g for rmi public serializableoptional string search int id public void log int id serializableoptional string item shows how to quickly wrap and unwrap an optional note that no local variable of type serializableoptional is needed private void callmethods for int id 0 id 7 id unwrap the returned optional using asoptional optional string searchresult search id asoptional wrap the optional using fromoptional if used often this could be a static import log id serializableoptional fromoptional searchresult fields of type optional the recommended approach to serialization is to use the serialization proxy pattern in that case there are two possibilities to serialize optional serializing the extracted value the proxy can simply have a field of the type which is wrapped by the optional in its constructor it then assigns the value contained in the optional or null if it is empty to that field this is done by the classusingoptionalcorrectly link private static class serializationproxy t implements serializable private final t optionalvalue public serializationproxy classusingoptionalcorrectly t classusingoptional optionalvalue classusingoptional optional orelse null using serializableoptional alternatively the serialization proxy can have an instance of serializableoptional this is done by the class transformforserializationproxy link private static class serializationproxy t implements serializable private final serializableoptional t optional public serializationproxy transformforserializationproxy t transform optional serializableoptional fromoptional transform optional the main difference to extracting the value is readability it makes it clearer that the logical representation contains an optional field the costs are an increased size of byte representation and more time to write it i didn t benchmark this so i can t tell whether this can be important i guess that as usual it depends reflection we have seen the two main and only reasons to serialize an optional and what to do about it if a method s arguments or return value needs to be serialized use the serializableoptional and immediately wrap unwrap it when the method is called if a class has an optional field which it wants to serialize its serialization proxy could either extract the optional s value or use write the serializableoptional to the byte stream the helper class serializableoptional from my demo project is public domain and can be used without any legal limitations bluesky mastodon discord youtube twitch github stackoverflow rss imprint privacy contact license
Images from subpage: "nipafx.dev/java-9/" Verify
Images from subpage: "nipafx.dev/java-basics/" Verify
Images from subpage: "nipafx.dev/java-next/" Verify
Images from subpage: "nipafx.dev/javafx/" Verify
Images from subpage: "nipafx.dev/jdeps/" Verify

Verified site has: 98 subpage(s). Do you want to verify them? Verify pages:

1-5 6-10 11-15 16-20 21-25 26-30 31-35 36-40 41-45 46-50
51-55 56-60 61-65 66-70 71-75 76-80 81-85 86-90 91-95 96-98


The site also has references to the 1 subdomain(s)

  slides.nipafx.dev  Verify


Top 50 hastags from of all verified websites.

Supplementary Information (add-on for SEO geeks)*- See more on header.verify-www.com

Header

HTTP/2 301
server GitHub.com
content-type text/html
x-origin-cache HIT
location htt????/nipafx.dev/serialize-java-optional/
access-control-allow-origin *
expires Mon, 14 Sep 2026 15:55:57 GMT
cache-control max-age=600
x-proxy-cache MISS
x-github-request-id D868:144279:7BE78A:7C929B:6AA816B4
x-github-edge-region fra
accept-ranges bytes
age 0
date Mon, 14 Sep 2026 15:45:57 GMT
via 1.1 varnish
x-served-by cache-rtm-ehrd2290050-RTM
x-cache MISS
x-cache-hits 0
x-timer S1789400757.921636,VS0,VE127
vary Accept-Encoding
x-fastly-request-id e71f7241dc6cec140d515a391b2ea44c75b79a35
content-length 162
HTTP/2 200
server GitHub.com
content-type text/html; charset=utf-8
last-modified Mon, 14 Sep 2026 15:39:58 GMT
access-control-allow-origin *
etag W/ 6aa8154e-2f770
expires Mon, 14 Sep 2026 15:55:57 GMT
cache-control max-age=600
content-encoding gzip
x-proxy-cache MISS
x-github-request-id 5F08:230A6:7F830A:802DF8:6AA816B5
x-github-edge-region fra
accept-ranges bytes
age 0
date Mon, 14 Sep 2026 15:45:57 GMT
via 1.1 varnish
x-served-by cache-rtm-ehrd2290050-RTM
x-cache MISS
x-cache-hits 0
x-timer S1789400757.058604,VS0,VE383
vary Accept-Encoding
x-fastly-request-id b4276e46d75eb9ae1224a79940ddb4d8747b2c5c
content-length 46110

Meta Tags

title="Serialize Optional // nipafx"
charset="utf-8"
http-equiv="x-ua-compatible" content="ie=edge"
name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"
name="generator" content="Gatsby 5.7.0"
data-react-helmet="true" name="description" content="A summary of why you can't serialize Optional and what can be done to deal with that limitation if necessary."
data-react-helmet="true" name="twitter:card" content="summary_large_image"
data-react-helmet="true" name="twitter:site" content="@nipafx"
data-react-helmet="true" name="twitter:creator" content="@nipafx"
data-react-helmet="true" name="twitter:title" content="Serialize Optional // nipafx"
data-react-helmet="true" name="twitter:description" content="A summary of why you can't serialize Optional and what can be done to deal with that limitation if necessary."
data-react-helmet="true" name="twitter:image" content="htt????/nipafx.dev/static/f00aeca12200f1b5c0d148e23c87aabf/91069/serialize-optional.jpg"
data-react-helmet="true" name="keywords" content="serialize optional"
data-react-helmet="true" property="og:title" content="Serialize Optional // nipafx"
data-react-helmet="true" property="og:type" content="article"
data-react-helmet="true" property="og:image" content="htt????/nipafx.dev/static/f00aeca12200f1b5c0d148e23c87aabf/91069/serialize-optional.jpg"
data-react-helmet="true" property="og:url" content="htt????/nipafx.dev/serialize-java-optional/"
data-react-helmet="true" property="og:description" content="A summary of why you can't serialize Optional and what can be done to deal with that limitation if necessary."
data-react-helmet="true" property="og:site_name" content="nipafx // You. Me. Java."
name="theme-color" content="#69ea7d"

Load Info

page size194416
load time (s)0.724907
redirect count1
speed download63687
server IP 185.199.108.153
* all occurrences of the string "http://" have been changed to "htt???/"