New Keywords in Java 9

后端 未结 5 1193
無奈伤痛
無奈伤痛 2021-01-31 07:53

One of Java 9\'s largest features will be a module system defined by Project Jigsaw. When reading slides from the Project Jigsaw: Under the Hood at JavaOne 2015, I noticed the f

5条回答
  •  既然无缘
    2021-01-31 08:35

    *

    module mainModule @ 2.0 {
    
        requires A @ >= 3.0 ;   // Use version 3 or above  
    
        //scope:compilation,execution,reflection
        requires B for compilation optional execution;
    
        requires optional service S1; 
        requires static E; // need at compile time but optional at runtime 
    
        // let mmm requires mainModule then S2 will automatically be there for mmm
        requires transitive S2; 
    
        provides MI @ 2.0; 
        provides service MS with C; // provide service with impelemented class C
    
        exports  pack;  
        exports  pack.abc to D; //qulified export
    
        permits  MF;
        class    MMain;
    
        /*
         syntax for creating view
         view ModuleName {
             {ProvidesDir|ExportsDir|PermitsDir|EntrypointDir}
         }
       */
    
        view N {
    
            provides service NS with AD;
            exports  MA;
            permits  MB;
            class    Main;
    
         }
    }
    

    * Check it out it may help you.

提交回复
热议问题