<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="atom.xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <id>https://osmerion.github.io/OptIn/blog</id>
    <title>OptIn Blog</title>
    <updated>2026-06-03T00:00:00.000Z</updated>
    <generator>https://github.com/jpmonette/feed</generator>
    <link rel="alternate" href="https://osmerion.github.io/OptIn/blog"/>
    <subtitle>OptIn Blog</subtitle>
    <icon>https://osmerion.github.io/OptIn/img/favicon.svg</icon>
    <entry>
        <title type="html"><![CDATA[Introducing opt-in requirements for Java APIs]]></title>
        <id>https://osmerion.github.io/OptIn/blog/welcome</id>
        <link href="https://osmerion.github.io/OptIn/blog/welcome"/>
        <updated>2026-06-03T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Every library author has been there: you have a new API that works, but you're not ready to commit to it forever.]]></summary>
        <content type="html"><![CDATA[<p>Every library author has been there: you have a new API that works, but you're not ready to commit to it forever.
Maybe the design will change. Maybe it's a low-level escape hatch that most users shouldn't touch. You add a note to the
JavaDoc - "experimental, use at your own risk" - and hope for the best.</p>
<p>Some projects introduce custom annotations like <code>@Beta</code> or <code>@Incubating</code> which are - with a few exceptions - unsupported
by IDEs and have no compiler support.</p>
<p>OptIn aims to standardize declaring and working with APIs that require explicit opt-in in Java.</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="kotlins-opt-in-requirements">Kotlin's opt-in requirements<a href="https://osmerion.github.io/OptIn/blog/welcome#kotlins-opt-in-requirements" class="hash-link" aria-label="Direct link to Kotlin's opt-in requirements" title="Direct link to Kotlin's opt-in requirements" translate="no">​</a></h2>
<p>Kotlin's opt-in requirements solve this problem elegantly. Library authors declare a <em>requirement marker</em> - a custom
annotation - and attach it to any API that requires explicit opt-in. Users can then opt in to the requirements locally
or propagate the requirements. The Kotlin compiler enforces that all requirements are satisfied at compile-time.</p>
<p>The result is opt-in as a contract, not a suggestion. Consumers can't stumble into an unstable API by accident. They
have to make a deliberate, visible choice.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="introducing-optin-for-java">Introducing OptIn for Java<a href="https://osmerion.github.io/OptIn/blog/welcome#introducing-optin-for-java" class="hash-link" aria-label="Direct link to Introducing OptIn for Java" title="Direct link to Introducing OptIn for Java" translate="no">​</a></h2>
<p>This project brings the same mechanism to Java.</p>
<p>At its core, OptIn for Java introduces two annotations:</p>
<ul>
<li class=""><code>@RequiresOptIn</code>  - a meta-annotation used to define requirement markers. You attach it to your own annotation
interface, giving it a message and a severity level (<code>WARNING</code> or <code>ERROR</code>). That annotation then
becomes the marker your users must acknowledge.</li>
<li class=""><code>@OptIn</code>          - the acknowledgment. Callers annotate their own code with <code>@OptIn(ExperimentalApi.class)</code> to say:
"I know what I'm doing, and I accept the risk."</li>
</ul>
<p>Requirements are contagious by design. An <code>@ExperimentalApi</code> class passes its requirement to all its members and nested
types. A method whose signature mentions an experimental type inherits the requirement automatically. This means
opt-in can't be circumvented by routing through an intermediary - the verifier sees through the whole chain.</p>
<p>OptIn implements javac plugin and an annotation processor that together form the verifier that verifies opt-in usage at
compile-time.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="try-optin-now">Try OptIn now!<a href="https://osmerion.github.io/OptIn/blog/welcome#try-optin-now" class="hash-link" aria-label="Direct link to Try OptIn now!" title="Direct link to Try OptIn now!" translate="no">​</a></h2>
<p>While the core aspects of the API and specification are unlikely to change, there are still a few details to iron out
and - presumably - issues to discover. We need your feedback now to finalize the specification! Please consider trying
out opt-in.</p>
<p><a href="https://osmerion.github.io/OptIn/docs/start-here.md" target="_blank" rel="noopener noreferrer" class="">Learn more!</a></p>]]></content>
        <author>
            <name>Leon Linhart</name>
            <uri>https://committing-crimes.com/about</uri>
        </author>
    </entry>
</feed>