profile
viewpoint

HappyHackingOrange/Sudoku 5

Sudoku game which uses a custom set instead of digits.

amrue/cinequest-wp8 2

Ciniquest app by Windows Phone 8 team, CS 175

cthuff/UndoViolet 1

This is group project for CS151 fall 2016. The project will be remaking the Violet UML diagram drawing tool to include an undo and redo function.

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 058730c0c863b79634cffadc12ce0c1f354305d9

...

view details

push time in 9 hours

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 657f97b98a7e63d463ec510810442eb943310e75

...

view details

push time in 9 hours

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 0c4fabc8e14ae9e493e98e191a83b32b8cb92942

...

view details

push time in 10 hours

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 5df198a8e2d36723f58a4b283a16caa6b55e7dda

...

view details

push time in 21 hours

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 22904769bba0d8761b97432b6b79857f9d08e62e

...

view details

push time in 21 hours

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha d8254bf1dd0d79f9a9e8ad077de44186314ae9d3

...

view details

push time in a day

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 2354b8e9c7b433bb0721b1089c9ab267f4b2dc3d

...

view details

push time in a day

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha cd5f5d2ab05264dd766418565ec7b35b8be1283d

...

view details

push time in a day

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 58430bd33f4d03e0f14340380dab7e2883c77904

...

view details

push time in a day

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha e1d6a8507b57b4c9c102568e5526fe41348f6340

...

view details

push time in a day

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha e0faca0224fa4a5733557f51036a62683a947d21

...

view details

push time in a day

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 19b03030b7daa057c0999efd3097a163dc5046c9

...

view details

push time in a day

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 4753ab416ac39eea293c9f1b30fb86a032cd9caa

...

view details

push time in a day

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 707233c3e3c821b2b152b05ee539ded2b1d33e3d

...

view details

push time in a day

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha a7fbfe69875d4651712067e835dc0c900e3d96b3

...

view details

push time in 14 days

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 84c2f0422ce2b9eb816136e97db86d64d5fda1ea

...

view details

push time in 15 days

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha b7499456f9ac360155c09d717e3f833ed0c0fd9c

LTI wip

view details

push time in 15 days

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha b9aaad11e6e0119f440f0574703d48bf2269fcd3

...

view details

push time in 16 days

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 4e4924a1e81d224fad83f31cd9159b9128e99c88

...

view details

push time in 16 days

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha ee8fdf6ac97ab63c28471a333913904fdb91992f

LTI wip

view details

push time in 16 days

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha dcf002ed42d3bc64b370b98420bc3421aca21f5c

...

view details

push time in 18 days

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha d6efee08628afeddb1bc9d7084f14dc4fe6fe95d

Fixed Clone button

view details

push time in 18 days

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 59b3a7e884858a4bc0a7d0ffcbcae948b1781bea

Dynamo table for assignments

view details

push time in 22 days

issue openedyshui/wimp

cargo install wimp fails on Ubuntu 20.04

cargo install wimp fails with the following error:

error[E0507]: cannot move out of `*self` which is behind a shared reference
   --> /home/cay/.cargo/registry/src/github.com-1ecc6299db9ec823/async-mutex-1.4.0/src/lib.rs:267:30
    |
267 |         if let Some(guard) = self.try_lock_arc() {
    |                              ^^^^ move occurs because `*self` has type `std::sync::Arc<Mutex<T>>`, which does not implement the `Copy` trait

error[E0308]: mismatched types
   --> /home/cay/.cargo/registry/src/github.com-1ecc6299db9ec823/async-mutex-1.4.0/src/lib.rs:410:9
    |
409 |     pub fn source(guard: &MutexGuardArc<T>) -> Arc<Mutex<T>> {
    |                                                ------------- expected `std::sync::Arc<Mutex<T>>` because of return type
410 |         &guard.0
    |         ^^^^^^^^
    |         |
    |         expected struct `std::sync::Arc`, found reference
    |         help: consider removing the borrow: `guard.0`
    |
    = note: expected struct `std::sync::Arc<Mutex<T>>`
            found reference `&std::sync::Arc<Mutex<T>>`

I have rust/cargo version 1.46.0

created time in 22 days

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 0c4a179a8763e3e2040758817e466e70e496f6ad

...

view details

push time in 23 days

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 865b752b1e5edfe5f341381f99d79a5d37bfe655

DynamoDB

view details

push time in 23 days

issue closedoracle/graal

Linker failure: undefined reference to `Java_java_util_prefs_FileSystemPreferences_chmod'

Describe the issue

Creating a native image fails with the above-mentioned linker issue.

Steps to reproduce the issue

cd /tmp
mkdir test
cd test
curl -O http://horstmann.com/codecheck/server/codecheck.tar.gz
tar xf codecheck.tar.gz
native-image --no-fallback -jar /opt/codecheck/codecheck.jar

Describe GraalVM and your environment:

GraalVM graalvm-ce-java11-20.2.0 JDK 11.0.4 OS: Ubuntu Linux 20.04.1 Arch. amd64

More details Consider adding the --native-image-info and --verbose flags when building your native image and paste output below.

Executing [
/data/apps/graalvm-ce-java11-20.2.0/bin/java \
-XX:+UseParallelGC \
-XX:+UnlockExperimentalVMOptions \
-XX:+EnableJVMCI \
-Dtruffle.TrustAllTruffleRuntimeProviders=true \
-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime \
-Dgraalvm.ForcePolyglotInvalid=true \
-Dgraalvm.locatorDisabled=true \
-Dsubstratevm.IgnoreGraalVersionCheck=true \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.sparc=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.sparc=ALL-UNNAMED \
--add-exports=org.graalvm.truffle/com.oracle.truffle.api=ALL-UNNAMED \
--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.debug=ALL-UNNAMED \
--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.nodes=ALL-UNNAMED \
--add-opens=jdk.unsupported/sun.reflect=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.module=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.reflect=ALL-UNNAMED \
--add-opens=java.base/java.io=ALL-UNNAMED \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED \
--add-opens=java.base/java.lang.ref=ALL-UNNAMED \
--add-opens=java.base/java.net=ALL-UNNAMED \
--add-opens=java.base/java.nio=ALL-UNNAMED \
--add-opens=java.base/java.nio.file=ALL-UNNAMED \
--add-opens=java.base/java.security=ALL-UNNAMED \
--add-opens=java.base/javax.crypto=ALL-UNNAMED \
--add-opens=java.base/java.util=ALL-UNNAMED \
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED \
--add-opens=java.base/sun.security.x509=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.logger=ALL-UNNAMED \
--add-opens=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED \
--add-opens=org.graalvm.sdk/org.graalvm.polyglot=ALL-UNNAMED \
--add-opens=org.graalvm.truffle/com.oracle.truffle.polyglot=ALL-UNNAMED \
--add-opens=org.graalvm.truffle/com.oracle.truffle.api.impl=ALL-UNNAMED \
-XX:+UseJVMCINativeLibrary \
-Xss10m \
-Xms1g \
-Xmx13150142464 \
-Duser.country=US \
-Duser.language=en \
-Djava.awt.headless=true \
-Dorg.graalvm.version=20.2.0 \
-Dorg.graalvm.config= \
-Dcom.oracle.graalvm.isaot=true \
-Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader \
-Xshare:off \
--module-path \
/data/apps/graalvm-ce-java11-20.2.0/lib/truffle/truffle-api.jar \
-javaagent:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/svm.jar \
-Djdk.internal.lambda.disableEagerInitialization=true \
-Djdk.internal.lambda.eagerlyInitialize=false \
-Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false \
-cp \
/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/pointsto.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/objectfile.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/llvm-platform-specific-shadowed.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/javacpp-shadowed.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/svm-llvm.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/llvm-wrapper-shadowed.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/svm.jar \
'com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus' \
-watchpid \
686809 \
-imagecp \
/data/apps/graalvm-ce-java11-20.2.0/lib/svm/library-support.jar:/opt/codecheck/codecheck.jar \
-H:Path=/tmp/ni \
-H:+DumpTargetInfo \
-H:FallbackThreshold=0 \
-H:Class=com.horstmann.codecheck.Runner \
-H:Name=codecheck \
-H:CLibraryPath=/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64 \

]
[codecheck:686828]    classlist:   1,744.89 ms,  0.96 GB
[codecheck:686828]        (cap):     866.34 ms,  0.96 GB
[codecheck:686828]        setup:   2,854.99 ms,  0.96 GB
# Building image for target platform: org.graalvm.nativeimage.Platform$LINUX_AMD64
# Using native toolchain:
#   Name: GNU project C and C++ compiler (gcc)
#   Vendor: linux
#   Version: 9.3.0
#   Target architecture: x86_64
#   Path: /usr/bin/gcc
# Using CLibrary: com.oracle.svm.core.posix.linux.libc.GLibC
[codecheck:686828]     (clinit):     325.15 ms,  2.30 GB
# Static libraries:
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/liblibchelper.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnet.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libffi.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnio.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libjava.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libfdlibm.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libzip.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libjvm.a
# Other libraries: pthread,dl,z,rt
[codecheck:686828]   (typeflow):  13,491.21 ms,  2.30 GB
[codecheck:686828]    (objects):   8,864.29 ms,  2.30 GB
[codecheck:686828]   (features):     612.62 ms,  2.30 GB
[codecheck:686828]     analysis:  23,883.39 ms,  2.30 GB
[codecheck:686828]     universe:   1,131.84 ms,  2.30 GB
[codecheck:686828]      (parse):   5,424.34 ms,  2.30 GB
[codecheck:686828]     (inline):   3,310.14 ms,  2.21 GB
[codecheck:686828]    (compile):  28,322.07 ms,  3.36 GB
[codecheck:686828]      compile:  38,708.37 ms,  3.36 GB
[codecheck:686828]        image:   2,814.41 ms,  3.36 GB
[codecheck:686828]        write:     401.15 ms,  3.36 GB
Fatal error:java.lang.RuntimeException: java.lang.RuntimeException: There was an error linking the native image: Linker command exited with 1

Linker command executed:
/usr/bin/gcc -z noexecstack -Wl,--gc-sections -Wl,--dynamic-list -Wl,/tmp/SVM-9303061323304520844/exported_symbols.list -Wl,--exclude-libs,ALL -Wl,-x -o /tmp/ni/codecheck /tmp/SVM-9303061323304520844/codecheck.o /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/liblibchelper.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnet.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libffi.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnio.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libjava.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libfdlibm.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libzip.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libjvm.a -v -L/tmp/SVM-9303061323304520844 -L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc -L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64 -lpthread -ldl -lz -lrt 

Linker command output:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-10ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2) 
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-z' 'noexecstack' '-o' '/tmp/ni/codecheck' '-v' '-L/tmp/SVM-9303061323304520844' '-L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc' '-L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccjvlmIi.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o /tmp/ni/codecheck -z noexecstack /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/tmp/SVM-9303061323304520844 -L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc -L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64 -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. --gc-sections --dynamic-list /tmp/SVM-9303061323304520844/exported_symbols.list --exclude-libs ALL -x /tmp/SVM-9303061323304520844/codecheck.o /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/liblibchelper.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnet.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libffi.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnio.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libjava.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libfdlibm.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libzip.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libjvm.a -lpthread -ldl -lz -lrt -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: /tmp/SVM-9303061323304520844/codecheck.o:(.data+0xbd8): undefined reference to `Java_java_util_prefs_FileSystemPreferences_chmod'
collect2: error: ld returned 1 exit status

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:600)
	at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1006)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:480)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:349)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:508)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:114)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:537)
Caused by: java.lang.RuntimeException: There was an error linking the native image: Linker command exited with 1

Linker command executed:
/usr/bin/gcc -z noexecstack -Wl,--gc-sections -Wl,--dynamic-list -Wl,/tmp/SVM-9303061323304520844/exported_symbols.list -Wl,--exclude-libs,ALL -Wl,-x -o /tmp/ni/codecheck /tmp/SVM-9303061323304520844/codecheck.o /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/liblibchelper.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnet.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libffi.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnio.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libjava.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libfdlibm.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libzip.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libjvm.a -v -L/tmp/SVM-9303061323304520844 -L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc -L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64 -lpthread -ldl -lz -lrt 

Linker command output:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-10ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2) 
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-z' 'noexecstack' '-o' '/tmp/ni/codecheck' '-v' '-L/tmp/SVM-9303061323304520844' '-L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc' '-L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccjvlmIi.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o /tmp/ni/codecheck -z noexecstack /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/tmp/SVM-9303061323304520844 -L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc -L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64 -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. --gc-sections --dynamic-list /tmp/SVM-9303061323304520844/exported_symbols.list --exclude-libs ALL -x /tmp/SVM-9303061323304520844/codecheck.o /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/liblibchelper.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnet.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libffi.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnio.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libjava.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libfdlibm.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libzip.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libjvm.a -lpthread -ldl -lz -lrt -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: /tmp/SVM-9303061323304520844/codecheck.o:(.data+0xbd8): undefined reference to `Java_java_util_prefs_FileSystemPreferences_chmod'
collect2: error: ld returned 1 exit status

	at com.oracle.svm.hosted.image.NativeBootImageViaCC.handleLinkerFailure(NativeBootImageViaCC.java:459)
	at com.oracle.svm.hosted.image.NativeBootImageViaCC.write(NativeBootImageViaCC.java:434)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:677)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:468)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
	at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1558)
	at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1308)
	at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1269)
	at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1228)
	at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1740)

closed time in a month

cayhorstmann

issue commentoracle/graal

Linker failure: undefined reference to `Java_java_util_prefs_FileSystemPreferences_chmod'

Thanks very much for the fast turnaround. It works with the added option.

cayhorstmann

comment created time in a month

issue commentoracle/graal

Linker failure: undefined reference to `Java_java_util_prefs_FileSystemPreferences_chmod'

Unfortunately, that makes no difference. It fails with the same linker error message.

cayhorstmann

comment created time in a month

issue openedoracle/graal

Linker failure: undefined reference to `Java_java_util_prefs_FileSystemPreferences_chmod'

Describe the issue

Creating a native image fails with the above-mentioned linker issue.

Steps to reproduce the issue

cd /tmp
mkdir test
cd test
curl -O http://horstmann.com/codecheck/server/codecheck.tar.gz
tar xf codecheck.tar.gz
native-image --no-fallback -jar /opt/codecheck/codecheck.jar

Describe GraalVM and your environment:

GraalVM graalvm-ce-java11-20.2.0 JDK 11.0.4 OS: Ubuntu Linux 20.04.1 Arch. amd64

More details Consider adding the --native-image-info and --verbose flags when building your native image and paste output below.

Executing [
/data/apps/graalvm-ce-java11-20.2.0/bin/java \
-XX:+UseParallelGC \
-XX:+UnlockExperimentalVMOptions \
-XX:+EnableJVMCI \
-Dtruffle.TrustAllTruffleRuntimeProviders=true \
-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime \
-Dgraalvm.ForcePolyglotInvalid=true \
-Dgraalvm.locatorDisabled=true \
-Dsubstratevm.IgnoreGraalVersionCheck=true \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.sparc=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.sparc=ALL-UNNAMED \
--add-exports=org.graalvm.truffle/com.oracle.truffle.api=ALL-UNNAMED \
--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.debug=ALL-UNNAMED \
--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.nodes=ALL-UNNAMED \
--add-opens=jdk.unsupported/sun.reflect=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.module=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.reflect=ALL-UNNAMED \
--add-opens=java.base/java.io=ALL-UNNAMED \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED \
--add-opens=java.base/java.lang.ref=ALL-UNNAMED \
--add-opens=java.base/java.net=ALL-UNNAMED \
--add-opens=java.base/java.nio=ALL-UNNAMED \
--add-opens=java.base/java.nio.file=ALL-UNNAMED \
--add-opens=java.base/java.security=ALL-UNNAMED \
--add-opens=java.base/javax.crypto=ALL-UNNAMED \
--add-opens=java.base/java.util=ALL-UNNAMED \
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED \
--add-opens=java.base/sun.security.x509=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.logger=ALL-UNNAMED \
--add-opens=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED \
--add-opens=org.graalvm.sdk/org.graalvm.polyglot=ALL-UNNAMED \
--add-opens=org.graalvm.truffle/com.oracle.truffle.polyglot=ALL-UNNAMED \
--add-opens=org.graalvm.truffle/com.oracle.truffle.api.impl=ALL-UNNAMED \
-XX:+UseJVMCINativeLibrary \
-Xss10m \
-Xms1g \
-Xmx13150142464 \
-Duser.country=US \
-Duser.language=en \
-Djava.awt.headless=true \
-Dorg.graalvm.version=20.2.0 \
-Dorg.graalvm.config= \
-Dcom.oracle.graalvm.isaot=true \
-Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader \
-Xshare:off \
--module-path \
/data/apps/graalvm-ce-java11-20.2.0/lib/truffle/truffle-api.jar \
-javaagent:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/svm.jar \
-Djdk.internal.lambda.disableEagerInitialization=true \
-Djdk.internal.lambda.eagerlyInitialize=false \
-Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false \
-cp \
/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/pointsto.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/objectfile.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/llvm-platform-specific-shadowed.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/javacpp-shadowed.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/svm-llvm.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/llvm-wrapper-shadowed.jar:/data/apps/graalvm-ce-java11-20.2.0/lib/svm/builder/svm.jar \
'com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus' \
-watchpid \
686809 \
-imagecp \
/data/apps/graalvm-ce-java11-20.2.0/lib/svm/library-support.jar:/opt/codecheck/codecheck.jar \
-H:Path=/tmp/ni \
-H:+DumpTargetInfo \
-H:FallbackThreshold=0 \
-H:Class=com.horstmann.codecheck.Runner \
-H:Name=codecheck \
-H:CLibraryPath=/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64 \

]
[codecheck:686828]    classlist:   1,744.89 ms,  0.96 GB
[codecheck:686828]        (cap):     866.34 ms,  0.96 GB
[codecheck:686828]        setup:   2,854.99 ms,  0.96 GB
# Building image for target platform: org.graalvm.nativeimage.Platform$LINUX_AMD64
# Using native toolchain:
#   Name: GNU project C and C++ compiler (gcc)
#   Vendor: linux
#   Version: 9.3.0
#   Target architecture: x86_64
#   Path: /usr/bin/gcc
# Using CLibrary: com.oracle.svm.core.posix.linux.libc.GLibC
[codecheck:686828]     (clinit):     325.15 ms,  2.30 GB
# Static libraries:
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/liblibchelper.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnet.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libffi.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnio.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libjava.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libfdlibm.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libzip.a
#   ../../data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libjvm.a
# Other libraries: pthread,dl,z,rt
[codecheck:686828]   (typeflow):  13,491.21 ms,  2.30 GB
[codecheck:686828]    (objects):   8,864.29 ms,  2.30 GB
[codecheck:686828]   (features):     612.62 ms,  2.30 GB
[codecheck:686828]     analysis:  23,883.39 ms,  2.30 GB
[codecheck:686828]     universe:   1,131.84 ms,  2.30 GB
[codecheck:686828]      (parse):   5,424.34 ms,  2.30 GB
[codecheck:686828]     (inline):   3,310.14 ms,  2.21 GB
[codecheck:686828]    (compile):  28,322.07 ms,  3.36 GB
[codecheck:686828]      compile:  38,708.37 ms,  3.36 GB
[codecheck:686828]        image:   2,814.41 ms,  3.36 GB
[codecheck:686828]        write:     401.15 ms,  3.36 GB
Fatal error:java.lang.RuntimeException: java.lang.RuntimeException: There was an error linking the native image: Linker command exited with 1

Linker command executed:
/usr/bin/gcc -z noexecstack -Wl,--gc-sections -Wl,--dynamic-list -Wl,/tmp/SVM-9303061323304520844/exported_symbols.list -Wl,--exclude-libs,ALL -Wl,-x -o /tmp/ni/codecheck /tmp/SVM-9303061323304520844/codecheck.o /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/liblibchelper.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnet.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libffi.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnio.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libjava.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libfdlibm.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libzip.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libjvm.a -v -L/tmp/SVM-9303061323304520844 -L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc -L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64 -lpthread -ldl -lz -lrt 

Linker command output:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-10ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2) 
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-z' 'noexecstack' '-o' '/tmp/ni/codecheck' '-v' '-L/tmp/SVM-9303061323304520844' '-L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc' '-L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccjvlmIi.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o /tmp/ni/codecheck -z noexecstack /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/tmp/SVM-9303061323304520844 -L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc -L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64 -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. --gc-sections --dynamic-list /tmp/SVM-9303061323304520844/exported_symbols.list --exclude-libs ALL -x /tmp/SVM-9303061323304520844/codecheck.o /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/liblibchelper.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnet.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libffi.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnio.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libjava.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libfdlibm.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libzip.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libjvm.a -lpthread -ldl -lz -lrt -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: /tmp/SVM-9303061323304520844/codecheck.o:(.data+0xbd8): undefined reference to `Java_java_util_prefs_FileSystemPreferences_chmod'
collect2: error: ld returned 1 exit status

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:600)
	at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1006)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:480)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:349)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:508)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:114)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:537)
Caused by: java.lang.RuntimeException: There was an error linking the native image: Linker command exited with 1

Linker command executed:
/usr/bin/gcc -z noexecstack -Wl,--gc-sections -Wl,--dynamic-list -Wl,/tmp/SVM-9303061323304520844/exported_symbols.list -Wl,--exclude-libs,ALL -Wl,-x -o /tmp/ni/codecheck /tmp/SVM-9303061323304520844/codecheck.o /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/liblibchelper.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnet.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libffi.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnio.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libjava.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libfdlibm.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libzip.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libjvm.a -v -L/tmp/SVM-9303061323304520844 -L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc -L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64 -lpthread -ldl -lz -lrt 

Linker command output:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-10ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2) 
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-z' 'noexecstack' '-o' '/tmp/ni/codecheck' '-v' '-L/tmp/SVM-9303061323304520844' '-L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc' '-L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccjvlmIi.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o /tmp/ni/codecheck -z noexecstack /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/tmp/SVM-9303061323304520844 -L/data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc -L/data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64 -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. --gc-sections --dynamic-list /tmp/SVM-9303061323304520844/exported_symbols.list --exclude-libs ALL -x /tmp/SVM-9303061323304520844/codecheck.o /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/liblibchelper.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnet.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libffi.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libnio.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libjava.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libfdlibm.a /data/apps/graalvm-ce-java11-20.2.0/lib/static/linux-amd64/glibc/libzip.a /data/apps/graalvm-ce-java11-20.2.0/lib/svm/clibraries/linux-amd64/libjvm.a -lpthread -ldl -lz -lrt -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: /tmp/SVM-9303061323304520844/codecheck.o:(.data+0xbd8): undefined reference to `Java_java_util_prefs_FileSystemPreferences_chmod'
collect2: error: ld returned 1 exit status

	at com.oracle.svm.hosted.image.NativeBootImageViaCC.handleLinkerFailure(NativeBootImageViaCC.java:459)
	at com.oracle.svm.hosted.image.NativeBootImageViaCC.write(NativeBootImageViaCC.java:434)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:677)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:468)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
	at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1558)
	at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1308)
	at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1269)
	at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1228)
	at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1740)

created time in a month

push eventcayhorstmann/java-almanac

Cay Horstmann

commit sha df2690c1c9b6346e90915434ca5dfd75693e47d1

Changed directory walk path, fixed typo

view details

push time in a month

issue commentcayhorstmann/ltihub

Reports truncated in /submissionViewer/

I see...I added document.body.style.overflow = 'auto' to the restoreState branch as well.

jmr-ua-pt

comment created time in a month

issue commentcayhorstmann/ltihub

Reports truncated in /submissionViewer/

I now tried this in Moodle as well, and I get two sets of scroll bars once I click on Submit. Screen shot below.

I am afraid I'll have to ask you to help with debugging. Inspect the frame that doesn't have the needed scrollbars (the one with prog2.py). Right-click, Inspect Element. Then find the body element enclosing it. There should be a hierarchy iframe -> #document -> html -> body. What is the overflow of that body element? Is it auto or is it hidden?

If it is hidden, look (under Debugger or Sources in the dev tools tab) for codecheck.it/assets/codecheck.js. What is line 66? Is it document.body.style.overflow = 'auto';? If not, there is a cache issue.

If it is, set a breakpoint on that line and revisit the page. (Just reloading might not be good enough. If you get a Failed OAuth Validation, navigate to it again in Moodle.) Does the breakpoint get triggered?

Screenshot_2020-09-13_07-35-44

jmr-ua-pt

comment created time in 2 months

push eventcayhorstmann/java-almanac

Cay Horstmann

commit sha 49d239536ff7d74ada22aba317dda12e6787319c

Changed title

view details

push time in 2 months

PullRequestEvent

pull request commentmarchof/java-almanac

Added sealedtypes

The JEP and the title of this article is "Sealed classes". For consistency shouldn't the files also be called sealedclasses?

Last time, I called all the files Sandbox.java, so I am consistent :-) Let me know if you want them renamed. I don't care either way.

I'm just talking about the filename of the article itself.

The JEP is obviously misnamed. I'd prefer to change the title.

cayhorstmann

comment created time in 2 months

push eventcayhorstmann/java-almanac

Cay Horstmann

commit sha 958634d29eab8a14b1b124c0d79f0f3ace3b1e24

Added reference

view details

push time in 2 months

push eventcayhorstmann/java-almanac

Cay Horstmann

commit sha 33fb73fa9efe1e3381b401e70b866536c15a64ef

Incorporated Marc's comments

view details

push time in 2 months

pull request commentmarchof/java-almanac

Added sealedtypes

The JEP and the title of this article is "Sealed classes". For consistency shouldn't the files also be called sealedclasses?

Last time, I called all the files Sandbox.java, so I am consistent :-) Let me know if you want them renamed. I don't care either way.

cayhorstmann

comment created time in 2 months

PR closed marchof/java-almanac

Added sealedtypes
+506 -0

4 comments

3 changed files

cayhorstmann

pr closed time in 2 months

pull request commentmarchof/java-almanac

Added sealedtypes

Do you have a chance to limit the json.png image to 800px? This is the width of the content column on javaalmanac.io, currently the image exceeds the right border.

Done

cayhorstmann

comment created time in 2 months

Pull request review commentmarchof/java-almanac

Added sealedtypes

+---+title: Sealed Classes (JEP 360)+copyright: Cay S. Horstmann 2020. All rights reserved.+jep: 360+jdkversion: 15+type: "sandbox"+---+++Java 15 provides a preview of “sealed types”—types with a fixed set of direct subtypes. This feature allows for accurate modeling of type hierarchies that should not be open to arbitrary inheritance, and it allows the compiler to check for exhaustive pattern matching.++## Controlling Subtypes++Unless a class is declared `final`, anyone can form a subclass of it. What if you want to have more control? For example, suppose you feel the need to write your own JSON library because none of the ones out there do exactly what you need.++The JSON standard says that a JSON value is an object, array, string, number, Boolean, or `null`. The Java language had, until now, no way of expressing that a `JSONValue` should be exactly one of those six types.++Java 15 provides a preview of “sealed types”, where you get just that control. You can define `JSONValue` to be `sealed`, and list the subclasses in a `permits` clause:++```+public sealed abstract class JSONValue+   permits JSONObject, JSONArray, JSONString, JSONNumber, JSONBoolean, JSONNull {+   . . .+}+```++If anyone were to form another subclass, such as++```+public class JSONComment extends JSONValue { . . . } // Error+```++this would be an error. And that's just as well, since JSON doesn't allow for comments. As you can see, sealed classes allow for accurate modeling of domain constraints. ++The dictionary defines sealing as (1) affixing a mark that attests to quality or absence of tampering, or (2) securing against access or damage. I am not sure that either of these describes what the `sealed` keyword does. A sealed class is protected from one specific evil, namely promiscuous subclassing.++```+public sealed abstract class JSONValue+      permits JSONObject, JSONArray, JSONString, JSONNumber, JSONBoolean, JSONNull {+   // . . .+}+```++```+public final class JSONObject extends JSONValue {+   // . . .+}+```++```+public final class JSONArray extends JSONValue {+   // . . .+}+```++```+public final class JSONString extends JSONValue {+   // . . .+}+```++```+public final class JSONNumber extends JSONValue {+   // . . .+}+```++```+public final class JSONBoolean extends JSONValue {+   // . . .+}+```++```+public final class JSONNull extends JSONValue {+   // . . .++}+```++```+public class Sandbox {+   public static void main(String[] args) {+      System.out.println("Move along, nothing to see here...");+   }+}+```++## Exhaustiveness++Sealed classes enable the compiler to reason about *exhaustiveness*. For example, in the following function, it would be possible for the compiler to conclude that no further `return` is needed:++```+public static String type(JSONValue value) {+   if (value == null) throw new NullPointerException;+   else if (value instanceof JSONObject) return "object";+   else if (value instanceof JSONArray) return "array";+   else if (value instanceof JSONString) return "string";+   else if (value instanceof JSONNumber) return "number";+   else if (value instanceof JSONBoolean) return "boolean";+   else if (value instanceof JSONNull) return "null";+}+```++Actually, Java 15 does not carry out that analysis for `if` statements, but it is likely that a  future version of Java will do this with type patterns in `switch` expressions:++```+public static String type(JSONValue value) {+   if (value == null) throw new NullPointerException;+   return switch (value) {+      case instanceof JSONObject -> "object"; // A guess at the syntax of the future+      case instanceof JSONArray -> "array";+      case instanceof JSONString -> "string";+      case instanceof JSONNumber -> "number";+      case instanceof JSONBoolean -> "boolean";+      case instanceof JSONNull -> "null";+      // No default needed here+   };+}+```++## Subclasses Must Specify Their Sealedness++At first glance, it appears as if a subclass of a sealed class must be `final`. But for exhaustiveness testing, we only need to know all *direct* subclasses. It is not a problem if those classes have further subclasses. For example, we can reorganize our JSON hierarchies like this:++![json.png](json.png)++Then the sealed `JSONValue` class permits three subclasses:++```+public sealed class JSONValue permits JSONObject, JSONArray, JSONPrimitive {+  . . .+}+```++What about `JSONPrimitive`? It should be a sealed class in its own right:++```+public sealed class JSONPrimitive extends JSONNode+      permits JSONString, JSONNumber, JSONBoolean, JSONNull {+  . . .+}+```++The other classes should be `final`.++```+public final class JSONObject extends JSONNode { . . . }+```++A subclass of a sealed class must specify whether it is `sealed`, `final`, or open for subclassing. In the latter case, it must be declared as `non-sealed`.++As an example, consider XML node types: elements, text, comments, CDATA sections, entity references, and processing instructions.++```+sealed class Node permits Element, Text, Comment,+      CDATASection, EntityReference, ProcessingInstruction {+   . . .+}+```++We might want to allow arbitrary subclasses of `Element` (as does with  `org.w3c.dom.Element`, which has dozens of HTML element subclasses). Then the declaration goes like this: ++```+non-sealed class Element extends Node {+   . . .+}+```++# New Keywords and Restricted Identifiers++The tokens `sealed` and `permits` are *restricted identifiers* that have a special meaning only in class and interface declarations, just like `record`, `var`, and `yield`. Code with variables named `sealed` and `permits` won't break. But you can no longer define classes named `sealed` and `permits`:++```+sealed class sealed permits permits {}+final class permits extends sealed {}+```++```+public class Sandbox {+   public static void main(String[] args) {+      System.out.println("Move along, nothing to see here...");+   }+}+```++In contrast, `non-sealed` is a keyword. Obviously, you cannot use it as an identifier since it contains a `-` character. In fact, `non-sealed` is the second keyword that contains a character that isn't a lowercase letter. The first one is `_`, since Java 9. I am sure++And yes, you can continue to compute the difference of two variables `non` and `sealed`:++```+public class Sandbox {+   public static void main(String[] args) {+      int non = 7 * 7;+      int sealed = 7;+      System.out.println(non-sealed);+   }+}+```++## Package/Module Restriction++If you don't use modules, then the sealed class and its direct subclasses must be in the same package. If you use modules, they must all be in the same module.++After all, these classes are developed and maintained together, so there should be no reason to spread them far and wide. ++There is one vexing situation. If you don't want to use modules, you cannot put the superclass into an API package and the subclasses into a separate implementation package.  ++## Omitting the Permits Clause++If the subclasses of a sealed class are all defined in the same source file, then you can omit the `permits` clause: ++```+import java.io.*;+import java.nio.file.*;+import java.util.function.*;+import java.util.stream.*;++sealed class DirectoryEntry { // No permits clause+   private Path path;+   public Path getPath() { return path; }++   // Direct subclasses in same source file+   public static final class Directory extends DirectoryEntry {+      private Directory() {}+      public Stream<DirectoryEntry> entries() {+         try {+            return Files.list(getPath()).map(DirectoryEntry::of);+         } catch (AccessDeniedException ex) {+            return Stream.empty();+         } catch (IOException ex) {+            throw new UncheckedIOException(ex);+         }+      }+   }++   public static final class File extends DirectoryEntry {+      private File() {}+   }++   public static final class Special extends DirectoryEntry {+      private Special() {}+   }++   public static DirectoryEntry of(Path path) {+      DirectoryEntry result; +      if (Files.isRegularFile(path)) result = new File();+      else if (Files.isDirectory(path)) result = new Directory();+      else result = new Special();+      result.path = path;+      return result;+   }+}+```++```+import java.io.*;+import java.nio.file.*;+import java.util.function.*;+import java.util.stream.*;++public class Sandbox+{+   public static void walk(DirectoryEntry entry, Consumer<DirectoryEntry> consumer) {+      consumer.accept(entry);+      if (entry instanceof DirectoryEntry.Directory d) {+         d.entries().forEach(e -> walk(e, consumer));+      }+   }++   public static void main(String[] args) throws Exception {+      walk(DirectoryEntry.of(Paths.get("/home")), e -> System.out.println(e.getPath())); +   }   +}+```++Then the permitted subclasses are all direct subclasses of the sealed class in the same source file. If you want the subclasses to be public, they must be nested classes, as in the example above.++If you omit the `permits` clause and there are no direct subclasses in the same source file, a compile-time error occurs.++## Sealed Interfaces++An interface can be sealed just like a class. It has a fixed set of permitted direct subtypes.++Here is an example. An integer sequence produces one integer after another, potentially infinitely many: ++```+public sealed interface IntSeq permits FiniteSeq, IteratedSeq, GeneratedSeq {+   int next();+   default boolean hasNext() { return true; }+}+```++There may be any number of ways of implementing finite sequences, and we aren't prescriptive:++```+public non-sealed interface FiniteSeq extends IntSeq {+   int size();+}+```++But for infinite sequences, we only support two implementations: with a generator function or an iterator function—similar to `Stream.generate` and `Stream.iterate`.++![seq.png](seq.png)++As you can see, with a sealed interface, the situation is a bit more complex. Its direct subtypes can be both interfaces and classes. But the rules are the same. All direct subtypes must be listed in the `permits` clause, or be in the same source file. And they must all be `final`, `sealed`, or `non-sealed`.++Sandbox with complete code:++```+public sealed interface IntSeq permits FiniteSeq, IteratedSeq, GeneratedSeq {+   int next();+   default boolean hasNext() { return true; }+}+```++```+public non-sealed interface FiniteSeq extends IntSeq {+   int size();+}+```++```+import java.util.function.*;++public final class GeneratedSeq implements IntSeq {+   private IntSupplier gen;+   public GeneratedSeq(IntSupplier gen) { this.gen = gen; }+   public int next() {+      return gen.getAsInt();+   }+}+```++```+import java.util.function.*;++final class IteratedSeq implements IntSeq {+   private IntUnaryOperator op;+   private int value;+   public IteratedSeq(IntUnaryOperator op, int seed) {+      this.op = op;+      value = seed;+   }+   public int next() {+      int result = value;+      value = op.applyAsInt(value);+      return result;+   }   +}+```++```+public class Sandbox {+   public static int sum(IntSeq seq, int n) {+      int sum = 0;+      while (seq.hasNext() && n > 0) { sum += seq.next(); n--; }+      return sum;+   }+   +   public static void main(String[] args) {+      var positiveIntegers = new IteratedSeq(x -> x + 1, 1);+      System.out.println(sum(positiveIntegers, 100));+   }+}+```++# Records and Enums++A sealed class can be extended by a record, which is implicitly `final`. Consider the classic example of a Lisp-style list:

Fixed to "A sealed interface can be implemented by a record"

cayhorstmann

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentmarchof/java-almanac

Added sealedtypes

+---+title: Sealed Classes (JEP 360)+copyright: Cay S. Horstmann 2020. All rights reserved.+jep: 360+jdkversion: 15+type: "sandbox"+---+++Java 15 provides a preview of “sealed types”—types with a fixed set of direct subtypes. This feature allows for accurate modeling of type hierarchies that should not be open to arbitrary inheritance, and it allows the compiler to check for exhaustive pattern matching.++## Controlling Subtypes++Unless a class is declared `final`, anyone can form a subclass of it. What if you want to have more control? For example, suppose you feel the need to write your own JSON library because none of the ones out there do exactly what you need.++The JSON standard says that a JSON value is an object, array, string, number, Boolean, or `null`. The Java language had, until now, no way of expressing that a `JSONValue` should be exactly one of those six types.++Java 15 provides a preview of “sealed types”, where you get just that control. You can define `JSONValue` to be `sealed`, and list the subclasses in a `permits` clause:++```+public sealed abstract class JSONValue+   permits JSONObject, JSONArray, JSONString, JSONNumber, JSONBoolean, JSONNull {+   . . .+}+```++If anyone were to form another subclass, such as++```+public class JSONComment extends JSONValue { . . . } // Error+```++this would be an error. And that's just as well, since JSON doesn't allow for comments. As you can see, sealed classes allow for accurate modeling of domain constraints. ++The dictionary defines sealing as (1) affixing a mark that attests to quality or absence of tampering, or (2) securing against access or damage. I am not sure that either of these describes what the `sealed` keyword does. A sealed class is protected from one specific evil, namely promiscuous subclassing.++```+public sealed abstract class JSONValue+      permits JSONObject, JSONArray, JSONString, JSONNumber, JSONBoolean, JSONNull {+   // . . .+}+```++```+public final class JSONObject extends JSONValue {+   // . . .+}+```++```+public final class JSONArray extends JSONValue {+   // . . .+}+```++```+public final class JSONString extends JSONValue {+   // . . .+}+```++```+public final class JSONNumber extends JSONValue {+   // . . .+}+```++```+public final class JSONBoolean extends JSONValue {+   // . . .+}+```++```+public final class JSONNull extends JSONValue {+   // . . .++}+```++```+public class Sandbox {+   public static void main(String[] args) {+      System.out.println("Move along, nothing to see here...");+   }+}+```++## Exhaustiveness++Sealed classes enable the compiler to reason about *exhaustiveness*. For example, in the following function, it would be possible for the compiler to conclude that no further `return` is needed:++```+public static String type(JSONValue value) {+   if (value == null) throw new NullPointerException;+   else if (value instanceof JSONObject) return "object";+   else if (value instanceof JSONArray) return "array";+   else if (value instanceof JSONString) return "string";+   else if (value instanceof JSONNumber) return "number";+   else if (value instanceof JSONBoolean) return "boolean";+   else if (value instanceof JSONNull) return "null";+}+```++Actually, Java 15 does not carry out that analysis for `if` statements, but it is likely that a  future version of Java will do this with type patterns in `switch` expressions:++```+public static String type(JSONValue value) {+   if (value == null) throw new NullPointerException;+   return switch (value) {+      case instanceof JSONObject -> "object"; // A guess at the syntax of the future+      case instanceof JSONArray -> "array";+      case instanceof JSONString -> "string";+      case instanceof JSONNumber -> "number";+      case instanceof JSONBoolean -> "boolean";+      case instanceof JSONNull -> "null";+      // No default needed here+   };+}+```++## Subclasses Must Specify Their Sealedness++At first glance, it appears as if a subclass of a sealed class must be `final`. But for exhaustiveness testing, we only need to know all *direct* subclasses. It is not a problem if those classes have further subclasses. For example, we can reorganize our JSON hierarchies like this:++![json.png](json.png)++Then the sealed `JSONValue` class permits three subclasses:++```+public sealed class JSONValue permits JSONObject, JSONArray, JSONPrimitive {+  . . .+}+```++What about `JSONPrimitive`? It should be a sealed class in its own right:++```+public sealed class JSONPrimitive extends JSONNode+      permits JSONString, JSONNumber, JSONBoolean, JSONNull {+  . . .+}+```++The other classes should be `final`.++```+public final class JSONObject extends JSONNode { . . . }+```++A subclass of a sealed class must specify whether it is `sealed`, `final`, or open for subclassing. In the latter case, it must be declared as `non-sealed`.++As an example, consider XML node types: elements, text, comments, CDATA sections, entity references, and processing instructions.++```+sealed class Node permits Element, Text, Comment,+      CDATASection, EntityReference, ProcessingInstruction {+   . . .+}+```++We might want to allow arbitrary subclasses of `Element` (as does with  `org.w3c.dom.Element`, which has dozens of HTML element subclasses). Then the declaration goes like this: ++```+non-sealed class Element extends Node {+   . . .+}+```++# New Keywords and Restricted Identifiers++The tokens `sealed` and `permits` are *restricted identifiers* that have a special meaning only in class and interface declarations, just like `record`, `var`, and `yield`. Code with variables named `sealed` and `permits` won't break. But you can no longer define classes named `sealed` and `permits`:++```+sealed class sealed permits permits {}+final class permits extends sealed {}+```++```+public class Sandbox {+   public static void main(String[] args) {+      System.out.println("Move along, nothing to see here...");+   }+}+```++In contrast, `non-sealed` is a keyword. Obviously, you cannot use it as an identifier since it contains a `-` character. In fact, `non-sealed` is the second keyword that contains a character that isn't a lowercase letter. The first one is `_`, since Java 9. I am sure

Removed it

cayhorstmann

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentmarchof/java-almanac

Added sealedtypes

+---+title: Sealed Classes (JEP 360)+copyright: Cay S. Horstmann 2020. All rights reserved.+jep: 360+jdkversion: 15+type: "sandbox"+---+++Java 15 provides a preview of “sealed types”—types with a fixed set of direct subtypes. This feature allows for accurate modeling of type hierarchies that should not be open to arbitrary inheritance, and it allows the compiler to check for exhaustive pattern matching.++## Controlling Subtypes++Unless a class is declared `final`, anyone can form a subclass of it. What if you want to have more control? For example, suppose you feel the need to write your own JSON library because none of the ones out there do exactly what you need.++The JSON standard says that a JSON value is an object, array, string, number, Boolean, or `null`. The Java language had, until now, no way of expressing that a `JSONValue` should be exactly one of those six types.++Java 15 provides a preview of “sealed types”, where you get just that control. You can define `JSONValue` to be `sealed`, and list the subclasses in a `permits` clause:++```+public sealed abstract class JSONValue+   permits JSONObject, JSONArray, JSONString, JSONNumber, JSONBoolean, JSONNull {+   . . .+}+```++If anyone were to form another subclass, such as++```+public class JSONComment extends JSONValue { . . . } // Error+```++this would be an error. And that's just as well, since JSON doesn't allow for comments. As you can see, sealed classes allow for accurate modeling of domain constraints. ++The dictionary defines sealing as (1) affixing a mark that attests to quality or absence of tampering, or (2) securing against access or damage. I am not sure that either of these describes what the `sealed` keyword does. A sealed class is protected from one specific evil, namely promiscuous subclassing.++```+public sealed abstract class JSONValue+      permits JSONObject, JSONArray, JSONString, JSONNumber, JSONBoolean, JSONNull {+   // . . .+}+```++```+public final class JSONObject extends JSONValue {+   // . . .+}+```++```+public final class JSONArray extends JSONValue {+   // . . .+}+```++```+public final class JSONString extends JSONValue {+   // . . .+}+```++```+public final class JSONNumber extends JSONValue {+   // . . .+}+```++```+public final class JSONBoolean extends JSONValue {+   // . . .+}+```++```+public final class JSONNull extends JSONValue {+   // . . .++}+```++```+public class Sandbox {

Yes, my bad. Something went wrong in the conversion from XHTML to Markdown. I just fixed that.

cayhorstmann

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentmarchof/java-almanac

Added sealedtypes

+---+title: Sealed Classes (JEP 360)+copyright: Cay S. Horstmann 2020. All rights reserved.+jep: 360+jdkversion: 15+type: "sandbox"+---+++Java 15 provides a preview of “sealed types”—types with a fixed set of direct subtypes. This feature allows for accurate modeling of type hierarchies that should not be open to arbitrary inheritance, and it allows the compiler to check for exhaustive pattern matching.++## Controlling Subtypes++Unless a class is declared `final`, anyone can form a subclass of it. What if you want to have more control? For example, suppose you feel the need to write your own JSON library because none of the ones out there do exactly what you need.++The JSON standard says that a JSON value is an object, array, string, number, Boolean, or `null`. The Java language had, until now, no way of expressing that a `JSONValue` should be exactly one of those six types.

Yes, it's an adjective derived from a person's name. https://english.stackexchange.com/questions/4481/should-the-word-boolean-be-capitalized. I'll change it to Boolean value.

cayhorstmann

comment created time in 2 months

PullRequestReviewEvent

issue commentcayhorstmann/ltihub

Reports truncated in /submissionViewer/

I just tried this in Canvas and had no problem with your Python assignment. Scroll bars show up in instructor view just as they do in student view. Maybe a cache issue? If the problem persists after clearing the browser cache, can you provide more info? Which browser? Which CodeCheck/LTIHub problem?

jmr-ua-pt

comment created time in 2 months

create barnchcayhorstmann/java-almanac

branch : sealedtypes

created branch time in 2 months

PR opened marchof/java-almanac

Added sealedtypes
+506 -0

0 comment

3 changed files

pr created time in 2 months

create barnchmarchof/java-almanac

branch : show-whitespace

created branch time in 2 months

issue closedcayhorstmann/ltihub

Report output truncated

I created a LTIHub assignment with Python exercises (https://play.codecheck.ws/lti/assignment?id=430) and when I press "Submit query" on an exercise, the table with the error/output report seems truncated after a few lines and has no scrollbar to allow viewing the rest. This is quite serious: it make it unusable.

Here goes a screenshot:

image

Back in July I used other LTIu assignments with no problem.

I'm using firefox. Changing the window size or zoom in the browser changes the amount of output visible.

closed time in 2 months

jmr-ua-pt

issue commentcayhorstmann/ltihub

Report output truncated

Thanks, that was caused by a change in CodeCheck. I made it so that scroll bars are added if necessary.

jmr-ua-pt

comment created time in 2 months

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha bb0e93eff731a57f3216beb9ce9657530e5dca55

...

view details

push time in 2 months

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha d82846c935e1b803cfe8bc2fe764e0e0f19cb7db

...

view details

push time in 2 months

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 9243974c58def38b4bd5944eb911cb807ed25944

...

view details

push time in 2 months

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 24d4611db56e7f58317d44f3fb388da8c598acf3

...

view details

push time in 2 months

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 192fa1aef999b0f042577bc3946437935171aa64

...

view details

push time in 2 months

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 022254fc2bd021f5e3fcef8443e6ecec65b302ca

...

view details

push time in 2 months

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 55df7a7a7a001d6015ed38147a4c2e8957686c36

...

view details

push time in 2 months

push eventcayhorstmann/play-codecheck

Cay Horstmann

commit sha 3adb0308eb8a41b4cc4e6498fff820eacedeeb44

...

view details

Cay Horstmann

commit sha 9658c83b4197a7d0be0aca3c83f5533e10a113ee

Assignments feature

view details

push time in 2 months

push eventcayhorstmann/ltihub

Cay Horstmann

commit sha 5f6117cd19314d9db6a723bf782db02d45b0db45

...

view details

push time in 2 months

push eventcayhorstmann/ltihub

Cay Horstmann

commit sha a7d9f16d3c814fc14c4640a7e8361e59cfa29eb7

...

view details

push time in 2 months

push eventcayhorstmann/ltihub

Cay Horstmann

commit sha cfb21a4b4b5ff6cf0f661f64122a0d779ac3a63e

...

view details

push time in 2 months

push eventcayhorstmann/ltihub

Cay Horstmann

commit sha fe2635a284964843c3d05c6091142295009c1dd9

...

view details

push time in 2 months

push eventcayhorstmann/ltihub

Cay Horstmann

commit sha b91f56635de545fa1fd023c3733ee8bf77e7bf90

...

view details

push time in 2 months

push eventcayhorstmann/ltihub

Cay Horstmann

commit sha 71ba7ce919c3ea235aca669ff9946f58313bc527

...

view details

push time in 2 months

push eventcayhorstmann/ltihub

Cay Horstmann

commit sha ae228fad9e39f63fbbe93f4b5675d8936d8722ed

...

view details

push time in 2 months

push eventcayhorstmann/ltihub

Cay Horstmann

commit sha 77cc473f973ef151fdf853fa109dd1387c71379f

...

view details

push time in 2 months

push eventcayhorstmann/ltihub

Cay Horstmann

commit sha 24f978e2c0f2955ecd89cc14faf0446cde01e23c

...

view details

push time in 2 months

push eventcayhorstmann/ltihub

Cay Horstmann

commit sha 2ce12b526e5e82059ba19a9142a791429293dc75

...

view details

push time in 2 months

push eventcayhorstmann/ltihub

Cay Horstmann

commit sha 23ea218ba535ccfa3c9042641dc25cc1aa2eca0d

...

view details

push time in 2 months

more