diff --git a/setup.cfg b/setup.cfg index 660b4e4..637382c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,7 +31,7 @@ keywords = project_urls = Documentation = https://docs.oracle.com/en/java/javase/17/docs/api/index.html Funding = https://github.com/sponsors/cesarcoatl - Source = https://github.com/ignition-devs/java-api/tree/main + Source = https://github.com/ignition-devs/java-api/tree/17 Tracker = https://github.com/ignition-devs/java-api/issues [options] diff --git a/src/java/lang/__init__.py b/src/java/lang/__init__.py index 0eacf3a..56675c7 100644 --- a/src/java/lang/__init__.py +++ b/src/java/lang/__init__.py @@ -29,6 +29,7 @@ "String", "StringBuffer", "StringBuilder", + "System", "Thread", "Throwable", "UnsupportedOperationException", @@ -36,14 +37,17 @@ import __builtin__ as builtins import array +import os import time from typing import TYPE_CHECKING, Any, List, Optional, Union from java.lang.reflect import Type if TYPE_CHECKING: + from java.io import InputStream, PrintStream from java.nio import CharBuffer - from java.util import Iterator, Spliterator + from java.nio.channels import Channel + from java.util import Iterator, Properties, Spliterator from java.util.function import Consumer from java.util.stream import IntStream, Stream @@ -683,6 +687,153 @@ def trimToSize(self): pass +class System(Object): + """The System class contains several useful class fields and + methods. + + It cannot be instantiated. Among the facilities provided by the + System class are standard input, standard output, and error output + streams; access to externally defined properties and environment + variables; a means of loading files and libraries; and a utility + method for quickly copying a portion of an array. + """ + + err = None # type: PrintStream + in_ = None # type: InputStream + out = None # type: PrintStream + + @staticmethod + def arraycopy(src, srcPos, dest, destPos, length): + # type: (Any, int, Any, int, int) -> None + pass + + @staticmethod + def clearProperty(key): + # type: (Union[str, unicode]) -> Union[str, unicode] + pass + + @staticmethod + def console(): + # type: () -> Any + pass + + @staticmethod + def currentTimeMillis(): + # type: () -> long + return long(time.time() * 1000) + + @staticmethod + def exit(status): + # type: (int) -> None + pass + + @staticmethod + def gc(): + # type: () -> None + pass + + @staticmethod + def getenv(name=None): + # type: (Optional[Union[str, unicode]]) -> Any + return dict(os.environ) if name is None else os.environ.get(str(name)) + + @staticmethod + def getLogger(name, bundle=None): + # type: (Union[str, unicode], Optional[Any]) -> Any + pass + + @staticmethod + def getProperties(): + # type: () -> Properties + pass + + @staticmethod + def getProperty( + key, # type: Union[str, unicode] + def_=None, # type: Optional[Union[str, unicode]] + ): + # type: (...) -> Union[str, unicode] + pass + + @staticmethod + def getSecurityManager(): + # type: () -> Any + pass + + @staticmethod + def identityHashCode(x): + # type: (Object) -> int + return id(x) + + @staticmethod + def inheritedChannel(): + # type: () -> Channel + pass + + @staticmethod + def lineSeparator(): + # type: () -> Union[str, unicode] + return os.linesep + + @staticmethod + def load(filename): + # type: (Union[str, unicode]) -> None + pass + + @staticmethod + def loadLibrary(libname): + # type: (Union[str, unicode]) -> None + pass + + @staticmethod + def mapLibraryName(libname): + # type: (Union[str, unicode]) -> Union[str, unicode] + pass + + @staticmethod + def nanoTime(): + # type: () -> long + return long(time.time() * 1000000000) + + @staticmethod + def runFinalization(): + # type: () -> None + pass + + @staticmethod + def setErr(err): + # type: (PrintStream) -> None + pass + + @staticmethod + def setIn(in_): + # type: (InputStream) -> None + pass + + @staticmethod + def setOut(out): + # type: (PrintStream) -> None + pass + + @staticmethod + def setProperties(props): + # type: (Properties) -> None + pass + + @staticmethod + def setProperty( + key, # type: Union[str, unicode] + value, # type: Union[str, unicode] + ): + # type: (...) -> Union[str, unicode] + pass + + @staticmethod + def setSecurityManager(sm): + # type: (Any) -> None + pass + + class Throwable(Object, builtins.Exception): """The Throwable class is the superclass of all errors and exceptions in the Java language. diff --git a/stubs/pyproject.toml b/stubs/pyproject.toml index 70b82e9..1b65d7d 100644 --- a/stubs/pyproject.toml +++ b/stubs/pyproject.toml @@ -38,10 +38,10 @@ classifiers = [ urls.Documentation = "https://docs.oracle.com/en/java/javase/17/docs/api/index.html" urls.Funding = "https://github.com/sponsors/cesarcoatl" urls.Homepage = "https://github.com/ignition-devs/java-api" -urls.Source = "https://github.com/ignition-devs/java-api/tree/main" +urls.Source = "https://github.com/ignition-devs/java-api/tree/17" urls.Tracker = "https://github.com/ignition-devs/java-api/issues" [tool.setuptools] -include-package-data = true package-dir = { "" = "stubs" } +include-package-data = true package-data."*" = [ "*.pyi", "py.typed" ] diff --git a/stubs/stubs/java/lang/__init__.pyi b/stubs/stubs/java/lang/__init__.pyi index 4e2ff29..9ddf8c2 100644 --- a/stubs/stubs/java/lang/__init__.pyi +++ b/stubs/stubs/java/lang/__init__.pyi @@ -1,9 +1,11 @@ import __builtin__ as builtins from typing import Any, List, Optional, Union +from java.io import InputStream, PrintStream from java.lang.reflect import Type from java.nio import CharBuffer -from java.util import Iterator, Spliterator +from java.nio.channels import Channel +from java.util import Iterator, Properties, Spliterator from java.util.function import Consumer from java.util.stream import IntStream, Stream @@ -197,6 +199,67 @@ class StringBuilder(Object, CharSequence): def substring(self, start: int, end: int = ...) -> Union[str, unicode]: ... def trimToSize(self) -> None: ... +class System(Object): + err: PrintStream + in_: InputStream + out: PrintStream + @staticmethod + def arraycopy( + src: Any, srcPos: int, dest: Any, destPos: int, length: int + ) -> None: ... + @staticmethod + def clearProperty(key: Union[str, unicode]) -> Union[str, unicode]: ... + @staticmethod + def console() -> Any: ... + @staticmethod + def currentTimeMillis() -> long: ... + @staticmethod + def exit(status: int) -> None: ... + @staticmethod + def gc() -> None: ... + @staticmethod + def getenv(name: Optional[Union[str, unicode]] = ...) -> Any: ... + @staticmethod + def getLogger(name: Union[str, unicode], bundle: Optional[Any] = ...) -> Any: ... + @staticmethod + def getProperties() -> Properties: ... + @staticmethod + def getProperty( + key: Union[str, unicode], def_: Optional[Union[str, unicode]] = ... + ) -> Union[str, unicode]: ... + @staticmethod + def getSecurityManager() -> Any: ... + @staticmethod + def identityHashCode(x: Object) -> int: ... + @staticmethod + def inheritedChannel() -> Channel: ... + @staticmethod + def lineSeparator() -> Union[str, unicode]: ... + @staticmethod + def load(filename: Union[str, unicode]) -> None: ... + @staticmethod + def loadLibrary(libname: Union[str, unicode]) -> None: ... + @staticmethod + def mapLibraryName(libname: Union[str, unicode]) -> Union[str, unicode]: ... + @staticmethod + def nanoTime() -> long: ... + @staticmethod + def runFinalization() -> None: ... + @staticmethod + def setErr(err: PrintStream) -> None: ... + @staticmethod + def setIn(in_: InputStream) -> None: ... + @staticmethod + def setOut(out: PrintStream) -> None: ... + @staticmethod + def setProperties(props: Properties) -> None: ... + @staticmethod + def setProperty( + key: Union[str, unicode], value: Union[str, unicode] + ) -> Union[str, unicode]: ... + @staticmethod + def setSecurityManager(sm: Any) -> None: ... + class Throwable(Object, builtins.Exception): def __init__( self, message: Optional[str] = ..., cause: Optional[Throwable] = ...