Skip to content

lib: put the configured service files into glibj.zip - #63

Merged
guillerodriguez merged 1 commit into
ingelabs:masterfrom
duncanmcqueen:fix-service-files
Oct 15, 2026
Merged

guillerodriguez merged 1 commit into
ingelabs:masterfrom
duncanmcqueen:fix-service-files

Conversation

@duncanmcqueen

Copy link
Copy Markdown
Contributor

Split from #59.

Problem and fix

configure makes three service files from .in templates:

  • META-INF/services/java.util.prefs.PreferencesFactory
  • META-INF/services/javax.sound.sampled.spi.AudioFileReader
  • META-INF/services/javax.sound.sampled.spi.MixerProvider

The resources rule in lib/Makefile.am copies META-INF from the source tree and skips the *.in files. In an out-of-tree build, the configured files are in the build tree, not in the source tree. Thus glibj.zip does not contain them. (If the source tree was also configured before, glibj.zip gets the old copies from the source tree.)

Then, for example, AudioSystem has no AudioFileReader, and it cannot read WAV or AU files.

The CI builds in the source tree. Thus the CI does not show the problem.

This change also copies the configured files from the build tree.

How to reproduce

mkdir build && cd build
../configure ...
make
unzip -l lib/glibj.zip | grep -o 'META-INF/services/[^.].*'

Then run this test:

javac WavFileFormat.java
java WavFileFormat
WavFileFormat.java
import java.io.*;
import javax.sound.sampled.*;

/**
 * AudioSystem must read the format of a WAV file. The WAV reader is
 * listed in META-INF/services/javax.sound.sampled.spi.AudioFileReader,
 * which configure makes from a .in template.
 */
public class WavFileFormat
{
  static void le(OutputStream o, int v, int n) throws IOException
  {
    for (int i = 0; i < n; i++)
      o.write(v >> (8 * i));
  }

  public static void main(String[] args) throws IOException
  {
    // A WAV file: 8000 Hz, 16 bit, mono, 4 samples.
    File f = File.createTempFile("wavfileformat", ".wav");
    f.deleteOnExit();
    OutputStream o = new FileOutputStream(f);
    o.write("RIFF".getBytes("US-ASCII")); le(o, 36 + 8, 4);
    o.write("WAVEfmt ".getBytes("US-ASCII")); le(o, 16, 4);
    le(o, 1, 2); le(o, 1, 2); le(o, 8000, 4); le(o, 16000, 4);
    le(o, 2, 2); le(o, 16, 2);
    o.write("data".getBytes("US-ASCII")); le(o, 8, 4);
    o.write(new byte[8]);
    o.close();
    try
      {
        AudioFileFormat fmt = AudioSystem.getAudioFileFormat(f);
        System.out.println("PASS: " + fmt.getType() + ", " + fmt.getFormat());
        System.exit(0);
      }
    catch (UnsupportedAudioFileException e)
      {
        System.out.println("FAIL: " + e);
        System.exit(1);
      }
  }
}

Results

Linux x86_64, ingelabs/classpath master (0406074), JamVM master, javac from JDK 8, autoconf 2.73, automake 1.19, the configure options of the CI Linux job, out-of-tree build. "Before" is master. "After" is master with this commit.

Before:
META-INF/services/javax.sound.midi.spi.MidiDeviceProvider
META-INF/services/javax.sound.midi.spi.MidiFileReader
META-INF/services/javax.sound.midi.spi.MidiFileWriter
FAIL: javax.sound.sampled.UnsupportedAudioFileException: file type not recognized

After:
META-INF/services/java.util.prefs.PreferencesFactory
META-INF/services/javax.sound.sampled.spi.AudioFileReader
META-INF/services/javax.sound.sampled.spi.MixerProvider
META-INF/services/javax.sound.midi.spi.MidiDeviceProvider
META-INF/services/javax.sound.midi.spi.MidiFileReader
META-INF/services/javax.sound.midi.spi.MidiFileWriter
PASS: WAVE, pcm_signed 8000.0 Hz 16 bits 1 channel little endian

Platforms

Not specific to Haiku. The problem occurs with all out-of-tree builds. I reproduced it on Linux.

AI assistance

An AI model (Claude Code, by Anthropic) wrote this change, the test and this text. The repository owner directed the work and checked the results. Please review it as you review other contributions.

🤖 Generated with Claude Code

Comment thread lib/Makefile.am
@guillerodriguez

Copy link
Copy Markdown
Contributor

@duncanmcqueen this is the next one we'd like to merge; please check the requested changes and let me know what you think.

The resources rule copies META-INF from the source tree and skips the
*.in templates. In an out-of-tree build the files that configure makes
from those templates are in the build tree, so glibj.zip did not get
them: java.util.prefs.PreferencesFactory,
javax.sound.sampled.spi.AudioFileReader and
javax.sound.sampled.spi.MixerProvider. (If the source tree was also
configured, glibj.zip got the stale copies from there.) Also copy the
configured files from the build tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: duncanmcqueen <dwmcqueen@gmail.com>
@guillerodriguez
guillerodriguez merged commit 0c353f9 into ingelabs:master Oct 15, 2026
3 checks passed
@duncanmcqueen
duncanmcqueen deleted the fix-service-files branch October 15, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants