How to use jdk.compiler module in jshell - javac

my jdk version is 17 and i want use com.sun.tools.javac.file.JavacFileManager class, My startup parameters are
$ jshell --add-modules jdk.compiler
then i typed
import com.sun.tools.javac.file.JavacFileManager;
I got a error like this:
| Error:
| package com.sun.tools.javac.file is not visible
| (package com.sun.tools.javac.file is declared in module jdk.compiler, which does not export it to the unnamed module)
| import com.sun.tools.javac.file.JavacFileManager;
| ^----------------------^
What should i do.

Access to JDK internal modules is not allowed since JEP 403.
To explicitly allow access in Java 17, one can use the option --add-exports while starting the JVM. This option also seems to work with jshel:
jshell --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports is docummented here:
--add-exports module/package=target-module(,target-module)*
Updates module to export package to target-module, regardless of module declaration. The target-module can be all unnamed to export to all unnamed modules.

Related

Where to set the path to the protoc to import standards Protocol Buffers

Where need I to set the path to the protoc to get import standards Protocol Buffers (protobuf), like empty.proto and timestamp.proto in Windows and Dart?
When the protoc is ran:
protoc --dart_out=grpc:lib/src/protos/generated -Iprotos
protos/organization.proto
--plugin=protoc-gen-dart=D:\Users\Samuel\AppData\Roaming\Pub\Cache\bin\protoc-gen-dart.bat
The following error is presented:
google/protobuf/empty.proto: File not found. organization.proto:
Import "google/protobuf/empty.proto" was not found or had errors.
organization.proto:14:27: "google.protobuf.Empty" is not defined.
In IntelliJ Settings on Protobuf Support plugin the path is define where standard protos (*.proto) are:
Additionally this path is define in IntelliJ on Project Structure \ Global Libraries:
The code organization.proto that import google/protobuf/empty.proto to use Empty class :
syntax = "proto3";
package auge.protobuf;
import "google/protobuf/empty.proto";
service OrganizationService {
rpc GetOrganizations (google.protobuf.Empty) returns (OrganizationsResponse) {}
}
IntelliJ analyzer recognizes the import "google/protobuf/empty.proto" and Empty class on IDEA, but protoc can not find.
The environment is:
SO: Windows 7 x64
protoc: libprotoc 3.6.1
Dart: 2.2.0-edge
Say you have /some/path/to/google/protobuf/empty.proto, you need to pass --proto_path=/some/path/to/ so protoc can locate it.
use two dot before protobuf folder path
<Protobuf Include="..\Proto\protobuf.proto" ProtoRoot="Proto" />

OpenWrt Package Makefile supporting multiple versions

Is there a way to have a single openwrt package Makefile support multiple "versions"?
For example, we have the following package "test1" Makefile:
...
PKG_NAME:=test1
PKG_VERSION:=1.2
PKG_RELEASE:=1
PKG_REV:=4f0c448faacfbcae185631ece73f196dc66851ca
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_REV).tar.gz
PKG_SOURCE_URL:=ssh://git#<>:123456/<remote>/test1.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
...
And we have a "test2" package which depends on this package:
...
define Package/$(PKG_NAME)
SECTION:=net
CATEGORY:=test
TITLE:=test2 package depending on test1
DEPENDS:=test1
endef
...
I want to have test1 package support multiple versions, whereas each version sets the PKG_REV hash differently, and a specific version to be "default".
I want test2 to select a specific version of test1 if test2 is selected in menuconfig.
What is the correct way to do that?

What Parameter set is correct for translating Java files to pascal units with Java2OP

My goal is to translate a Java Project (3 .java files) to .pas files with Embarcadero's Java2OP tool.
I'm using it via cmd, started in the java2op directory. After several unsuccessful tries, and a lot of time of googling, I am frustrated.
Commands in the documentation:
Input Options
-------------
-classes Space-separated list of names of classes or packages to export. -classes lets
you define a specific subset of the specified Java sources (-jar or -source options)
or the Android API.
-jar Space-separated list of input Java compiled libraries (.jar files).
-source Space-separated list of input folders containing Java source files (.java files).
Output Options
--------------
-unit File name of the output unit.
Default: Android.JNI.Interfaces
Examples
--------
Exporting some classes and packages from the Android API:
Java2OP.exe -classes android.net.ConnectivityManager android.location.*
Exporting all classes from mylib.jar:
Java2OP.exe -jar mylib.jar
Exporting a single class from mylib.jar:
Java2OP.exe -jar mylib.jar -classes com.mypackage.ClassName
Exporting all the classes from a folder of Java sources specifying the
file name of the output Delphi unit:
Java2OP.exe -source myproject/src -unit Android.JNI.UnitName
My commands:
java2op.exe -src A:\Tests -unit Android.JNI.TestFile
So it matches the guidelines:
Java2OP.exe -source myproject/src -unit Android.JNI.UnitName
If I try to change -src to the suggested -source, I get the following error:
Invalid option: -source
After executing the command, 1 error occurs:
Command: javadoc -J-Xmx1024m -encoding "UTF-8" -sourcepath "A:\java2op\Java"
-subpackages "" -classpath "" -bootclasspath "A:\java2op\bootclasses.jar" -docletpath "A:\java2op\doclava.jar"
-doclet com.google.doclava.Doclava -nodocs -public -apixml "A:\java2op\temp.xml"
Output: javadoc: error - Illegal package name: "" 1 error
I read the following post about the same issue:
How can I extract a Delphi class from this JAVA file for use with Android?
but without success.
What am I missing or doing wrong?

Julia use of JLD: WARNING: Module HDF5 uuid did not match cache file

When I run using JLD I get the following warnings:
INFO: Recompiling stale cache file C:\Julia\PkgDir\lib\v0.4\JLD.ji for module JLD.
WARNING: Module HDF5 uuid did not match cache file
This is likely because module HDF5 does not support precompilation but is imported by a module that does.
WARNING: deserialization checks failed while attempting to load cache from C:\Julia\PkgDir\lib\v0.4\JLD.ji
INFO: Precompiling module JLD...
INFO: Recompiling stale cache file C:\Julia\PkgDir\lib\v0.4\JLD.ji for module JLD.
WARNING: Module HDF5 uuid did not match cache file
This is likely because module HDF5 does not support precompilation but is imported by a module that does.
__precompile__(true) but require failed to create a precompiled cache file
If I then run say:
A=ones(40)
save("c:\\OneDrive\\Model\\myfile.jld", "A", A)
I get the error:
UndefVarError: save not defined in include_string at loading.jl:288 in eval at
C:\Julia\PkgDir\v0.4\Atom\src\Atom.jl:3 [inlined code] from
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:39 in anonymous at
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:108 in withpath at
C:\Julia\PkgDir\v0.4\Requires\src\require.jl:37 in withpath at
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:53 [inlined code] from
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:107 in anonymous at task.jl:58
I'm using Atom 1.8.0 and Julia 0.4.7. I'm using JLD as, to the best of my knowledge, it's the only pkg that allows me to write variables to file and preserve all of their attributes.
I had a similar issue with JLD at one point and running Pkg.update() fixed it. Updating to the latest stable Julia version before running the package update could also be helpful.

grails - The requested resource is not available when adding new method to controller in interactive mode

I am new to Grails, learning about its basics. One of the first things I did was to follow the presentation on https://grails.org/learn. According to that it should be possible to add a new method to a controller while the application is running in interactive mode (launched by the run-app target), and access that method as an action without the need to restart the application.
When I was trying to do so, I got an error message 404 from the web server with the explanation: "The requested resource is not available". The new method does work fine after the application is restarted.
I am using:
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS"
$ java -version
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) Client VM (build 24.65-b04, mixed mode)
$ grails -version
Grails version: 2.4.3
The steps I did:
$ grails create-app grailsapp
| Created Grails Application at /home/marci/grailsapp
$ cd grailsapp/
$ grails
| Daemon Started
grails> create-controller hello
| Compiling 10 source files
| Compiling 131 source files
| Created file grails-app/controllers/grailsapp/HelloController.groovy
| Created file grails-app/views/hello
| Created file test/unit/grailsapp/HelloControllerSpec.groovy
grails>
I implemented index() in grails-app/controllers/grailsapp/HelloController.groovy:
package grailsapp
class HelloController {
def index() {
render "index"
}
}
Saved the file, ran the app:
grails> run-app
| Running Grails application
| Server running. Browse to http://localhost:8080/grailsapp
| Application loaded in interactive mode. Type 'stop-app' to shutdown.
| Enter a script name to run. Use TAB for completion:
grails>
Checked http://localhost:8080/grailsapp/hello/index with the browser, worked fine.
Now I added another method:
package grailsapp
class HelloController {
def index() {
render "index"
}
def somemethod() {
render "somemethod"
}
}
Saved the file. Grails seems to have noticed the change in the source code and recompiled the file:
| Compiling 1 source files
| Compiling 1 source files.
| Compiling 1 source files..
| Compiling 1 source files...
| Compiling 1 source files....
| Compiling 1 source files.....
grails>
Now if I try to access the new method by the URL http://localhost:8080/grailsapp/hello/somemethod from the browser then Tomcat says:
HTTP Status 404 -
type Status report
message
description The requested resource is not available.
Apache Tomcat/7.0.55
Note that the message is empty. If I try to access a method that does not exist, I do get a message, therefore a different error. For example http://localhost:8080/grailsapp/hello/doesnotexist :
HTTP Status 404 - /grailsapp/hello/doesnotexist
type Status report
message /grailsapp/hello/doesnotexist
description The requested resource is not available.
Apache Tomcat/7.0.55
If I restart the application in interactive mode and try the somemethod action again, then it works fine.
grails> stop-app
| Server Stopped
grails> run-app
| Running Grails application
| Server running. Browse to http://localhost:8080/grailsapp
| Application loaded in interactive mode. Type 'stop-app' to shutdown.
| Enter a script name to run. Use TAB for completion:
grails>
Now http://localhost:8080/grailsapp/hello/somemethod return the response I expect.
My question is, should the new action be available without restart, as it is demonstrated in the presentation? Is this a bug in the release 2.4.3 of Grails? Or should I do something more to activate this feature?
Thanks in advance,
Marton
should the new action be available without restart, as it is
demonstrated in the presentation?
Yes.
Is this a bug in the release 2.4.3 of Grails?
Yes.
Or should I do something more to activate this feature?
No, you should not have to do something more.
The reloading agent should work when you are in interactive mode but apparently isn't. If you file an issue at https://jira.grails.org/browse/GRAILS we can take a look at that.
Thanks for the feedback.

Resources