import typing

import java
import java.lang
import java.util.concurrent

class Cleaner(java.lang.Object):
    @typing.overload
    @staticmethod
    def create() -> Cleaner: ...
    @typing.overload
    @staticmethod
    def create(threadFactory: java.util.concurrent.ThreadFactory, /) -> Cleaner: ...
    def register(self, obj: java.lang.Object | int | bool | float | str, action: java.lang.Runnable, /) -> Cleaner.Cleanable: ...

    class Cleanable(java.lang.Object):
        def clean(self) -> None: ...

_PhantomReference__T = typing.TypeVar('_PhantomReference__T')  # <T>
class PhantomReference(Reference[_PhantomReference__T], typing.Generic[_PhantomReference__T]):
    def __init__(self, referent: _PhantomReference__T, q: ReferenceQueue[_PhantomReference__T], /) -> None: ...
    def get(self) -> _PhantomReference__T | None: ...

_Reference__T = typing.TypeVar('_Reference__T')  # <T>
class Reference(java.lang.Object, typing.Generic[_Reference__T]):
    def clear(self) -> None: ...
    def clone(self) -> java.lang.Object: ...
    def enqueue(self) -> bool: ...
    def get(self) -> _Reference__T | None: ...
    def isEnqueued(self) -> bool: ...
    @staticmethod
    def reachabilityFence(ref: java.lang.Object | int | bool | float | str, /) -> None: ...
    def refersTo(self, obj: _Reference__T, /) -> bool: ...

_ReferenceQueue__T = typing.TypeVar('_ReferenceQueue__T')  # <T>
class ReferenceQueue(java.lang.Object, typing.Generic[_ReferenceQueue__T]):
    def __init__(self) -> None: ...
    def poll(self) -> Reference[_ReferenceQueue__T] | None: ...
    @typing.overload
    def remove(self) -> Reference[_ReferenceQueue__T]: ...
    @typing.overload
    def remove(self, timeout: int | java.jlong | java.lang.Long, /) -> Reference[_ReferenceQueue__T]: ...

_SoftReference__T = typing.TypeVar('_SoftReference__T')  # <T>
class SoftReference(Reference[_SoftReference__T], typing.Generic[_SoftReference__T]):
    @typing.overload
    def __init__(self, referent: _SoftReference__T, /) -> None: ...
    @typing.overload
    def __init__(self, referent: _SoftReference__T, q: ReferenceQueue[_SoftReference__T], /) -> None: ...
    def get(self) -> _SoftReference__T | None: ...

_WeakReference__T = typing.TypeVar('_WeakReference__T')  # <T>
class WeakReference(Reference[_WeakReference__T], typing.Generic[_WeakReference__T]):
    @typing.overload
    def __init__(self, referent: _WeakReference__T, /) -> None: ...
    @typing.overload
    def __init__(self, referent: _WeakReference__T, q: ReferenceQueue[_WeakReference__T], /) -> None: ...
