Providing Java library, but hiding some classes

后端 未结 6 1435
鱼传尺愫
鱼传尺愫 2020-12-15 08:32

I am developing an application in Java ME that I want to provide as a library. Is there no way to hide classes that I don\'t want everyone to use, but is essential still in

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-15 09:18

    If Java 9 is possible, use Jigsaw modules. If not, put every class on the same package, with package-level access for hidden classes, and use Maven modules to organize them.

    I've done exactly that in my project called coronata, a Wii Remote java library. Almost all classes are in package com.github.awvalenti.bauhinia.coronata, but on different modules (which appear as projects on the IDE).

    Visible classes are public. They are in modules:

    • coronata-api
    • coronata-builder
    • coronata-demos
    • coronata-lib

    Hidden classes have package-level acesss. They are in modules:

    • coronata-common
    • coronata-implementation-bluecove
    • coronata-implementation-wiiusej

提交回复
热议问题