Unable to make field private final java.lang.String java.io.File.path accessible: module java.base

1.错误信息如下:

Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module

2.解决方法:

--add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.io=ALL-UNNAMED \
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8  --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
  --add-opens=java.base/java.lang=ALL-UNNAMED \
  --add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
  --add-opens=java.base/java.io=ALL-UNNAMED \
  --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
#???? Entry name 'assets/HttpServerResource/audio/test.wav' collided???
android.useNewApkCreator=false
org.gradle.warning.mode=all

  • 10
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
单词 音标 注释 a collection of… 一组… a couple of… 几个 a kind of 一种 a number of… 许多… a point in time n.时间点 a set of… 一组… a series of 一系列 ability [ə'bɪlətɪ] n.能力 absence [ˈæbsəns] n.缺席,不存在 absolute [ˈæbsəlu:t] adj.绝对的 abstract [ˈæbstrækt] adj.抽象的 abstraction [æbˈstrækʃn] n.抽象 access [ˈækses] v.访问 accessed adj.访问的 accessible [əkˈsesəbl] adj.可访问的 accessor [ˈæksesə] n.访问 accidental [ˌæksɪˈdentl] adj.意外的 accommodate [ə'kɒmədeɪt] v.容纳,适应 accompany [ə'kʌmpənɪ] v.陪同 accomplish [ə'kʌmplɪʃ] v.完成 accordion [əˈkɔ:diən] adj.可折叠的 account [ə'kaʊnt] accountable [əˈkaʊntəbl] adj.负有责任的 accumulate [ə'kju:mjəleɪt] v.累积 accurate [ˈækjərət] adj.精确的 act as… v.充当… action [ˈækʃən] n.操作 activation [ˌæktɪ'veɪʃn] n.激活 active [ˈæktɪv] adj.活跃的 actively ['æktɪvlɪ] adv.主动地 actual [ˈæktʃuəl] adj.真实的 actually [ˈæktʃuəli] adv.实际上 across… 在…间 adaptation [ˌædæp'teɪʃn] n.改编 adapter [əˈdæptə] n.适配器 add [æd] v.增加 adequate [ˈædɪkwət] adj.足够的 addition [əˈdɪʃn] n.加 additional [ə'dɪʃənl] adj.附加的 address [əˈdres] n.地址 adjacent [əˈdʒeɪsnt] adj.邻近的 adjust [ə'dʒʌst] v.调整 advance [əd'vɑ:ns] v.提前,向前一步 advance..past.. 将…移至…后 advise [əd'vaɪz] v.建议 affect [ə'fekt] v.影响 ahead [əˈhed] adv.预先 alert [ə'lɜ:t] v.警示 alias [ˈeɪliəs] n.别名 align [əˈlaɪn] v.对齐 algorithm ['ælɡərɪðəm] n.算法 allocate ['æləkeɪt] v.分配 allocation [ˌæləˈkeɪʃn] n.分配 alow v.支持 allowable [əˈlaʊəbl] adj.允许的 alone [əˈləun] adj.单独的 along with… 以及…
Programming skills are indispensable in today’s world, not just for computer science students, but also for anyone in any scientific or technical discipline. Introduction to Programming in Java, Second Edition, by Robert Sedgewick and Kevin Wayne is an accessible, interdisciplinary treatment that emphasizes important and engaging applications, not toy problems. The authors supply the tools needed for students and professionals to learn that programming is a natural, satisfying, and creative experience, and to become conversant with one of the world’s most widely used languages. This example-driven guide focuses on Java’s most useful features and brings programming to life for every student in the sciences, engineering, and computer science. Coverage includes Basic elements of programming: variables, assignment statements, built-in data types, conditionals, loops, arrays, and I/O, including graphics and sound Functions, modules, and libraries: organizing programs into components that can be independently debugged, maintained, and reused Algorithms and data structures: sort/search algorithms, stacks, queues, and symbol tables Applications from applied math, physics, chemistry, biology, and computer science Drawing on their extensive classroom experience, throughout the text the authors provide Q&As;, exercises, and opportunities for creative engagement with the material. Together with the companion materials described below, this book empowers people to pursue a modern approach to teaching and learning programming. Companion web site (introcs.cs.princeton.edu/java) contains Chapter summaries Supplementary exercises, some with solutions Detailed instructions for installing a Java programming environment Program code and test data suitable for easy download Detailed creative exercises, projects, and other supplementary materials Companion studio-produced online videos (informit.com/sedgewick) are available for purchase and provide students and professionals with th
这个错误是由于Java 9及以上版本的模块化系统引起的。在Java 9中,模块化系统被引入以提供更好的代码隔离和模块化。在模块化系统中,模块可以选择性地将其包暴露给其他模块。 在你提到的错误中,"Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io"",它表示你的代码试图访问`java.io.File`类的私有字段`path`,但是由于`java.base`模块没有将`java.io`包打开(opens)给其他模块,所以无法访问该字段。 要解决这个问题,你可以使用反射来访问私有字段。通过使用反射,你可以绕过访问限制并访问私有字段。下面是一个使用反射访问私有字段的示例代码: ```java import java.lang.reflect.Field; import java.io.File; public class Main { public static void main(String[] args) throws Exception { File file = new File("path/to/file"); Field pathField = File.class.getDeclaredField("path"); pathField.setAccessible(true); String pathValue = (String) pathField.get(file); System.out.println("File path: " + pathValue); } } ``` 上述代码中,我们使用`getDeclaredField`方法获取`File`类的私有字段`path`,然后通过`setAccessible(true)`方法将其设置为可访问。最后,我们使用`get`方法获取字段的值。 请注意,使用反射来访问私有字段可能会破坏封装性,并且不推荐在正常的应用程序中频繁使用。只有在特殊情况下,比如需要进行调试或者实现某些特定的功能时,才应该使用反射来访问私有字段。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值