Program: 154058
Project: 154058
Buggy source:
/** 
 * Constructs an <code>CompositeOpImage</code>.
 * @param source1             The foreground source image.
 * @param source2             The background source image.
 * @param layout              The destination image layout.
 * @param source1Alpha        The alpha image that overrides thealpha for source1; may not be null.
 * @param source2Alpha        The alpha image that overrides the alpha forsource2; may be null, in which case source2 is considered completely opaque.
 * @param alphaPremultiplied  Indicates whether alpha has beenpremultiplied to both sources.
 * @param alphaFirst          If true, alpha is the first band (band 0) indestination image; if false, alpha is the last band.
 */
public CompositeOpImage(RenderedImage source1,RenderedImage source2,Map config,ImageLayout layout,RenderedImage source1Alpha,RenderedImage source2Alpha,boolean alphaPremultiplied,boolean alphaFirst){
  super(source1,source2,layout,config,true);
  this.source1Alpha=source1Alpha;
  this.source2Alpha=source2Alpha;
  this.alphaPremultiplied=alphaPremultiplied;
  SampleModel sm=source1.getSampleModel();
  int dtype=sm.getTransferType();
  int bands=sm.getNumBands() + 1;
  if (sampleModel.getTransferType() != dtype || sampleModel.getNumBands() != bands) {
    sampleModel=RasterFactory.createComponentSampleModel(sampleModel,dtype,tileWidth,tileHeight,bands);
    if (colorModel != null && !JDKWorkarounds.areCompatibleDataModels(sampleModel,colorModel)) {
      colorModel=ImageUtil.getCompatibleColorModel(sampleModel,config);
    }
  }
  aOffset=alphaFirst ? 0 : bands - 1;
  cOffset=alphaFirst ? 1 : 0;
switch (dtype) {
case DataBuffer.TYPE_BYTE:
    maxValue=0xFF;
  maxValueByte=(byte)0xFF;
break;
case DataBuffer.TYPE_USHORT:
maxValue=0xFFFF;
maxValueShort=(short)0xFFFF;
break;
case DataBuffer.TYPE_SHORT:
maxValue=Short.MAX_VALUE;
maxValueShort=Short.MAX_VALUE;
break;
case DataBuffer.TYPE_INT:
maxValue=Integer.MAX_VALUE;
break;
default :
}
invMaxValue=1.0F / maxValue;
}

Fixed version (ground truth):
/** 
 * Constructs an <code>CompositeOpImage</code>.
 * @param source1             The foreground source image.
 * @param source2             The background source image.
 * @param layout              The destination image layout.
 * @param source1Alpha        The alpha image that overrides thealpha for source1; may not be null.
 * @param source2Alpha        The alpha image that overrides the alpha forsource2; may be null, in which case source2 is considered completely opaque.
 * @param alphaPremultiplied  Indicates whether alpha has beenpremultiplied to both sources.
 * @param alphaFirst          If true, alpha is the first band (band 0) indestination image; if false, alpha is the last band.
 */
public CompositeOpImage(RenderedImage source1,RenderedImage source2,Map config,ImageLayout layout,RenderedImage source1Alpha,RenderedImage source2Alpha,boolean alphaPremultiplied,boolean alphaFirst){
  super(source1,source2,layout,config,true);
  this.source1Alpha=source1Alpha;
  this.source2Alpha=source2Alpha;
  this.alphaPremultiplied=alphaPremultiplied;
  SampleModel sm=source1.getSampleModel();
  ColorModel cm=source1.getColorModel();
  int dtype=sm.getTransferType();
  int bands;
  if (cm instanceof IndexColorModel) {
    bands=cm.getNumComponents();
  }
 else {
    bands=sm.getNumBands();
  }
  bands+=1;
  if (sampleModel.getTransferType() != dtype || sampleModel.getNumBands() != bands) {
    sampleModel=RasterFactory.createComponentSampleModel(sampleModel,dtype,tileWidth,tileHeight,bands);
    if (colorModel != null && !JDKWorkarounds.areCompatibleDataModels(sampleModel,colorModel)) {
      colorModel=ImageUtil.getCompatibleColorModel(sampleModel,config);
    }
  }
  aOffset=alphaFirst ? 0 : bands - 1;
  cOffset=alphaFirst ? 1 : 0;
switch (dtype) {
case DataBuffer.TYPE_BYTE:
    maxValue=0xFF;
  maxValueByte=(byte)0xFF;
break;
case DataBuffer.TYPE_USHORT:
maxValue=0xFFFF;
maxValueShort=(short)0xFFFF;
break;
case DataBuffer.TYPE_SHORT:
maxValue=Short.MAX_VALUE;
maxValueShort=Short.MAX_VALUE;
break;
case DataBuffer.TYPE_INT:
maxValue=Integer.MAX_VALUE;
break;
default :
}
invMaxValue=1.0F / maxValue;
}