Uploaded image for project: 'Commons JCI'
  1. Commons JCI
  2. JCI-25

ClassFormatException during Javaflow class enhancement

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      org.apache.bcel.classfile.ClassFormatException: null is not a Java .class file
      at org.apache.bcel.classfile.ClassParser.readID(ClassParser.java:286)
      at org.apache.bcel.classfile.ClassParser.parse(ClassParser.java:155)
      at org.apache.commons.javaflow.bytecode.transformation.bcel.BcelClassTransformer.transform(BcelClassTransformer.java:117)
      at org.apache.commons.javaflow.stores.TransformingResourceStore.write(TransformingResourceStore.java:50)
      at org.apache.commons.javaflow.stores.JavaflowResourceStore.onStop(JavaflowResourceStore.java:81)
      at org.apache.cocoon.components.flow.java.JavaflowResourceStore.onStop(JavaflowResourceStore.java:101)
      at org.apache.commons.jci.listeners.ReloadingListener.onStop(ReloadingListener.java:120)
      at org.apache.commons.jci.monitor.FilesystemAlterationMonitor.onStop(FilesystemAlterationMonitor.java:261)
      at org.apache.commons.jci.monitor.FilesystemAlterationMonitor.run(FilesystemAlterationMonitor.java:420)
      at java.lang.Thread.run(Thread.java:595)

      The exception is triggered because the bytecode of the .class file is not recognized; the error resides in org.apache.commons.jci.listeners.ReloadingListener, that uses a FileReader to read the file and converts it in a stream of characters :

      .........
      final File file = (File) it.next();
      try {
      final byte[] bytes = IOUtils.toByteArray(new FileReader(file));
      final String resourceName = ReloadingClassLoader.clazzName(repository, file);
      //if (resourceName.endsWith(".class")) {
      store.write(resourceName, bytes);
      ........

      Using FileInputStream it works correctly; all relevant tests work.
      Attaching patch.

      Attachments

        1. commons-jci.diff
          2 kB
          Maurizio Pillitu

        Activity

          People

            Unassigned Unassigned
            mauriziop Maurizio Pillitu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: