marschall / memoryfilesystem

An in memory implementation of a JSR-203 file system
282 stars 36 forks source link

Generate module-info.java #111

Closed ferstl closed 5 years ago

ferstl commented 5 years ago

This PR generates the module-info.class File with the modulemaker-maven-plugin This eliminates a lot of maven-compiler-plugin configs.

I made a quick comparison of the compiled and the generated version. They are semantically similar:

Generated version

javap -v target/classes/module-info.class
 Classfile /C:/Users/sferstl/git/memoryfilesystem/target/classes/module-info.class
  Last modified 23.09.2018; size 656 bytes
  MD5 checksum f334b734f256a9f4808478fe2df3757a
module com.github.marschall.memoryfilesystem
  minor version: 0
  major version: 53
  flags: (0x8000) ACC_MODULE
  this_class: #2                          // "module-info"
  super_class: #0
  interfaces: 0, fields: 0, methods: 0, attributes: 1
Constant pool:
   #1 = Utf8               module-info
   #2 = Class              #1             // "module-info"
   #3 = Utf8               com.github.marschall.memoryfilesystem
   #4 = Module             #3             // "com.github.marschall.memoryfilesystem"
   #5 = Utf8               java.annotation
   #6 = Module             #5             // "java.annotation"
   #7 = Utf8               java.base
   #8 = Module             #7             // "java.base"
   #9 = Utf8               com/github/marschall/memoryfilesystem
  #10 = Package            #9             // com/github/marschall/memoryfilesystem
  #11 = Utf8               java/nio/file/spi/FileSystemProvider
  #12 = Class              #11            // java/nio/file/spi/FileSystemProvider
  #13 = Utf8               com/github/marschall/memoryfilesystem/MemoryFileSystemProvider
  #14 = Class              #13            // com/github/marschall/memoryfilesystem/MemoryFileSystemProvider
  #15 = Utf8               Module
{
}
Module:
  #4,0                                    // "com.github.marschall.memoryfilesystem"
  #0
  2                                       // requires
    #6,40                                   // "java.annotation" ACC_STATIC_PHASE
    #0
    #8,8000                                 // "java.base" ACC_MANDATED
    #0
  1                                       // exports
    #10,0                                   // com/github/marschall/memoryfilesystem
  0                                       // opens
  0                                       // uses
  1                                       // provides
    #12                                     // java/nio/file/spi/FileSystemProvider with ... 1
      #14                                     // ... with com/github/marschall/memoryfilesystem/MemoryFileSystemProvider

Compiled version

javap -v target/classes/module-info.class
Classfile /C:/Users/sferstl/git/memoryfilesystem/target/classes/module-info.class
  Last modified 23.09.2018; size 377 bytes
  MD5 checksum f2038526ab1b4c1dbdf7272341db32ab
  Compiled from "module-info.java"
module com.github.marschall.memoryfilesystem
  minor version: 0
  major version: 54
  flags: (0x8000) ACC_MODULE
  this_class: #1                          // "module-info"
  super_class: #0
  interfaces: 0, fields: 0, methods: 0, attributes: 2
Constant pool:
   #1 = Class              #12            // "module-info"
   #2 = Utf8               SourceFile
   #3 = Utf8               module-info.java
   #4 = Utf8               Module
   #5 = Module             #13            // "com.github.marschall.memoryfilesystem"
   #6 = Module             #14            // "java.base"
   #7 = Utf8               10.0.2
   #8 = Module             #15            // "java.annotation"
   #9 = Package            #16            // com/github/marschall/memoryfilesystem
  #10 = Class              #17            // java/nio/file/spi/FileSystemProvider
  #11 = Class              #18            // com/github/marschall/memoryfilesystem/MemoryFileSystemProvider
  #12 = Utf8               module-info
  #13 = Utf8               com.github.marschall.memoryfilesystem
  #14 = Utf8               java.base
  #15 = Utf8               java.annotation
  #16 = Utf8               com/github/marschall/memoryfilesystem
  #17 = Utf8               java/nio/file/spi/FileSystemProvider
  #18 = Utf8               com/github/marschall/memoryfilesystem/MemoryFileSystemProvider
{
}
SourceFile: "module-info.java"
Module:
  #5,0                                    // "com.github.marschall.memoryfilesystem"
  #0
  2                                       // requires
    #6,8000                                 // "java.base" ACC_MANDATED
    #7                                      // 10.0.2
    #8,40                                   // "java.annotation" ACC_STATIC_PHASE
    #0
  1                                       // exports
    #9,0                                    // com/github/marschall/memoryfilesystem
  0                                       // opens
  0                                       // uses
  1                                       // provides
    #10                                     // java/nio/file/spi/FileSystemProvider with ... 1
      #11                                     // ... with com/github/marschall/memoryfilesystem/MemoryFileSystemProvider