Skip to content

Commit b33fa26

Browse files
authored
feat: add java.lang.System (#56)
update package and stubs Source URL
1 parent b9e9fb6 commit b33fa26

6 files changed

Lines changed: 226 additions & 12 deletions

File tree

‎.github/workflows/pip-compile-upgrade.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
branch: ['8.1', '8.3']
13+
branch: ['17', '25']
1414
fail-fast: false
1515
steps:
1616
- name: Checkout repo
@@ -19,26 +19,26 @@ jobs:
1919
ref: ${{ matrix.branch }}
2020

2121
- name: Upgrade package requirements
22-
uses: coatl-dev/actions/pip-compile-upgrade@499c77f2bc6f909d372849058517ca2e39ce16d4 # v7.1.3
22+
uses: coatl-dev/actions/pip-compile-upgrade@c339f0299e21b3b28b42414e3ea474d33468713c # v7.1.5
2323
with:
2424
path: requirements.txt
2525

2626
- name: Upgrade stubs requirements
27-
uses: coatl-dev/actions/uv-pip-compile-upgrade@499c77f2bc6f909d372849058517ca2e39ce16d4 # v7.1.3
27+
uses: coatl-dev/actions/uv-pip-compile-upgrade@c339f0299e21b3b28b42414e3ea474d33468713c # v7.1.5
2828
with:
2929
path: requirements.txt
3030
python-version: '3.12'
3131
working-directory: stubs
3232

3333
- name: Detect changes
3434
id: git-diff
35-
uses: coatl-dev/actions/simple-git-diff@499c77f2bc6f909d372849058517ca2e39ce16d4 # v7.1.3
35+
uses: coatl-dev/actions/simple-git-diff@c339f0299e21b3b28b42414e3ea474d33468713c # v7.1.5
3636
with:
3737
path: ${{ github.workspace }}
3838

3939
- name: Import GPG key
4040
if: ${{ steps.git-diff.outputs.diff == 'true' }}
41-
uses: coatl-dev/actions/gpg-import@499c77f2bc6f909d372849058517ca2e39ce16d4 # v7.1.3
41+
uses: coatl-dev/actions/gpg-import@c339f0299e21b3b28b42414e3ea474d33468713c # v7.1.5
4242
with:
4343
passphrase: ${{ secrets.COATL_BOT_GPG_PASSPHRASE }}
4444
private-key: ${{ secrets.COATL_BOT_GPG_PRIVATE_KEY }}
@@ -63,7 +63,7 @@ jobs:
6363
6464
- name: Create pull request
6565
if: ${{ steps.git-diff.outputs.diff == 'true' }}
66-
uses: coatl-dev/actions/pr-create@499c77f2bc6f909d372849058517ca2e39ce16d4 # v7.1.3
66+
uses: coatl-dev/actions/pr-create@c339f0299e21b3b28b42414e3ea474d33468713c # v7.1.5
6767
with:
6868
gh-token: ${{ secrets.COATL_BOT_GH_TOKEN }}
6969
base-branch: '${{ matrix.branch }}'

‎setup.cfg‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ keywords =
2929
inductive automation
3030
java
3131
project_urls =
32-
Documentation = https://docs.oracle.com/en/java/javase/17/docs/api/index.html
32+
Documentation = https://docs.oracle.com/en/java/javase/25/docs/api/index.html
3333
Funding = https://github.com/sponsors/cesarcoatl
34-
Source = https://github.com/ignition-devs/java-api/tree/main
34+
Source = https://github.com/ignition-devs/java-api/tree/25
3535
Tracker = https://github.com/ignition-devs/java-api/issues
3636

3737
[options]

‎src/java/lang/__init__.py‎

Lines changed: 152 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"String",
3333
"StringBuffer",
3434
"StringBuilder",
35+
"System",
3536
"Thread",
3637
"Throwable",
3738
"UnsupportedOperationException",
@@ -40,15 +41,18 @@
4041

4142
import __builtin__ as builtins
4243
import array
44+
import os
4345
import time
4446
from typing import TYPE_CHECKING, Any, List, Optional, Set, Union
4547

4648
from java.lang.reflect import AccessFlag, Type
4749

4850
if TYPE_CHECKING:
51+
from java.io import InputStream, PrintStream
4952
from java.nio import CharBuffer
53+
from java.nio.channels import Channel
5054
from java.time import Duration
51-
from java.util import Iterator, Spliterator
55+
from java.util import Iterator, Properties, Spliterator
5256
from java.util.concurrent import ThreadFactory
5357
from java.util.function import Consumer, Supplier
5458
from java.util.stream import IntStream, Stream
@@ -714,6 +718,153 @@ def trimToSize(self):
714718
pass
715719

716720

721+
class System(Object):
722+
"""The System class contains several useful class fields and
723+
methods.
724+
725+
It cannot be instantiated. Among the facilities provided by the
726+
System class are standard input, standard output, and error output
727+
streams; access to externally defined properties and environment
728+
variables; a means of loading files and libraries; and a utility
729+
method for quickly copying a portion of an array.
730+
"""
731+
732+
err = None # type: PrintStream
733+
in_ = None # type: InputStream
734+
out = None # type: PrintStream
735+
736+
@staticmethod
737+
def arraycopy(src, srcPos, dest, destPos, length):
738+
# type: (Any, int, Any, int, int) -> None
739+
dest[destPos : destPos + length] = src[srcPos : srcPos + length]
740+
741+
@staticmethod
742+
def clearProperty(key):
743+
# type: (Union[str, unicode]) -> Union[str, unicode]
744+
pass
745+
746+
@staticmethod
747+
def console():
748+
# type: () -> Any
749+
pass
750+
751+
@staticmethod
752+
def currentTimeMillis():
753+
# type: () -> long
754+
return long(time.time() * 1000)
755+
756+
@staticmethod
757+
def exit(status):
758+
# type: (int) -> None
759+
pass
760+
761+
@staticmethod
762+
def gc():
763+
# type: () -> None
764+
pass
765+
766+
@staticmethod
767+
def getenv(name=None):
768+
# type: (Optional[Union[str, unicode]]) -> Any
769+
return dict(os.environ) if name is None else os.environ.get(str(name))
770+
771+
@staticmethod
772+
def getLogger(name, bundle=None):
773+
# type: (Union[str, unicode], Optional[Any]) -> Any
774+
pass
775+
776+
@staticmethod
777+
def getProperties():
778+
# type: () -> Properties
779+
pass
780+
781+
@staticmethod
782+
def getProperty(
783+
key, # type: Union[str, unicode]
784+
def_=None, # type: Optional[Union[str, unicode]]
785+
):
786+
# type: (...) -> Union[str, unicode]
787+
pass
788+
789+
@staticmethod
790+
def getSecurityManager():
791+
# type: () -> Any
792+
pass
793+
794+
@staticmethod
795+
def identityHashCode(x):
796+
# type: (Object) -> int
797+
return id(x)
798+
799+
@staticmethod
800+
def inheritedChannel():
801+
# type: () -> Channel
802+
pass
803+
804+
@staticmethod
805+
def lineSeparator():
806+
# type: () -> Union[str, unicode]
807+
return os.linesep
808+
809+
@staticmethod
810+
def load(filename):
811+
# type: (Union[str, unicode]) -> None
812+
pass
813+
814+
@staticmethod
815+
def loadLibrary(libname):
816+
# type: (Union[str, unicode]) -> None
817+
pass
818+
819+
@staticmethod
820+
def mapLibraryName(libname):
821+
# type: (Union[str, unicode]) -> Union[str, unicode]
822+
pass
823+
824+
@staticmethod
825+
def nanoTime():
826+
# type: () -> long
827+
return long(time.time() * 1000000000)
828+
829+
@staticmethod
830+
def runFinalization():
831+
# type: () -> None
832+
pass
833+
834+
@staticmethod
835+
def setErr(err):
836+
# type: (PrintStream) -> None
837+
pass
838+
839+
@staticmethod
840+
def setIn(in_):
841+
# type: (InputStream) -> None
842+
pass
843+
844+
@staticmethod
845+
def setOut(out):
846+
# type: (PrintStream) -> None
847+
pass
848+
849+
@staticmethod
850+
def setProperties(props):
851+
# type: (Properties) -> None
852+
pass
853+
854+
@staticmethod
855+
def setProperty(
856+
key, # type: Union[str, unicode]
857+
value, # type: Union[str, unicode]
858+
):
859+
# type: (...) -> Union[str, unicode]
860+
pass
861+
862+
@staticmethod
863+
def setSecurityManager(sm):
864+
# type: (Any) -> None
865+
pass
866+
867+
717868
class Throwable(Object, builtins.Exception):
718869
"""The Throwable class is the superclass of all errors and
719870
exceptions in the Java language.

‎stubs/pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ classifiers = [
3838
urls.Documentation = "https://docs.oracle.com/en/java/javase/25/docs/api/index.html"
3939
urls.Funding = "https://github.com/sponsors/cesarcoatl"
4040
urls.Homepage = "https://github.com/ignition-devs/java-api"
41-
urls.Source = "https://github.com/ignition-devs/java-api/tree/main"
41+
urls.Source = "https://github.com/ignition-devs/java-api/tree/25"
4242
urls.Tracker = "https://github.com/ignition-devs/java-api/issues"
4343

4444
[tool.setuptools]

‎stubs/stubs/java/lang/__init__.pyi‎

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import __builtin__ as builtins
22
from typing import Any, List, Optional, Set, Union
33

4+
from java.io import InputStream, PrintStream
45
from java.lang.reflect import AccessFlag, Type
56
from java.nio import CharBuffer
7+
from java.nio.channels import Channel
68
from java.time import Duration
7-
from java.util import Iterator, Spliterator
9+
from java.util import Iterator, Properties, Spliterator
810
from java.util.concurrent import ThreadFactory
911
from java.util.function import Consumer, Supplier
1012
from java.util.stream import IntStream, Stream
@@ -217,6 +219,67 @@ class StringBuilder(Object, CharSequence):
217219
def substring(self, start: int, end: int = ...) -> Union[str, unicode]: ...
218220
def trimToSize(self) -> None: ...
219221

222+
class System(Object):
223+
err: PrintStream
224+
in_: InputStream
225+
out: PrintStream
226+
@staticmethod
227+
def arraycopy(
228+
src: Any, srcPos: int, dest: Any, destPos: int, length: int
229+
) -> None: ...
230+
@staticmethod
231+
def clearProperty(key: Union[str, unicode]) -> Union[str, unicode]: ...
232+
@staticmethod
233+
def console() -> Any: ...
234+
@staticmethod
235+
def currentTimeMillis() -> long: ...
236+
@staticmethod
237+
def exit(status: int) -> None: ...
238+
@staticmethod
239+
def gc() -> None: ...
240+
@staticmethod
241+
def getenv(name: Optional[Union[str, unicode]] = ...) -> Any: ...
242+
@staticmethod
243+
def getLogger(name: Union[str, unicode], bundle: Optional[Any] = ...) -> Any: ...
244+
@staticmethod
245+
def getProperties() -> Properties: ...
246+
@staticmethod
247+
def getProperty(
248+
key: Union[str, unicode], def_: Optional[Union[str, unicode]] = ...
249+
) -> Union[str, unicode]: ...
250+
@staticmethod
251+
def getSecurityManager() -> Any: ...
252+
@staticmethod
253+
def identityHashCode(x: Object) -> int: ...
254+
@staticmethod
255+
def inheritedChannel() -> Channel: ...
256+
@staticmethod
257+
def lineSeparator() -> Union[str, unicode]: ...
258+
@staticmethod
259+
def load(filename: Union[str, unicode]) -> None: ...
260+
@staticmethod
261+
def loadLibrary(libname: Union[str, unicode]) -> None: ...
262+
@staticmethod
263+
def mapLibraryName(libname: Union[str, unicode]) -> Union[str, unicode]: ...
264+
@staticmethod
265+
def nanoTime() -> long: ...
266+
@staticmethod
267+
def runFinalization() -> None: ...
268+
@staticmethod
269+
def setErr(err: PrintStream) -> None: ...
270+
@staticmethod
271+
def setIn(in_: InputStream) -> None: ...
272+
@staticmethod
273+
def setOut(out: PrintStream) -> None: ...
274+
@staticmethod
275+
def setProperties(props: Properties) -> None: ...
276+
@staticmethod
277+
def setProperty(
278+
key: Union[str, unicode], value: Union[str, unicode]
279+
) -> Union[str, unicode]: ...
280+
@staticmethod
281+
def setSecurityManager(sm: Any) -> None: ...
282+
220283
class Throwable(Object, builtins.Exception):
221284
def __init__(
222285
self, message: Optional[str] = ..., cause: Optional[Throwable] = ...

‎tox.ini‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ wrap-summaries = 72
3939
arg-type-hints-in-docstring = False
4040
arg-type-hints-in-signature = False
4141
check-return-types = False
42-
ignore = DOC202, E741, F821
42+
ignore = DOC202, E203, E741, F821
4343
max-complexity = 10
4444
max-doc-length = 72
4545
max-line-length = 120

0 commit comments

Comments
 (0)