Scan class.

@param bits
the bits

@throws IOException
Signals that an I/O exception has occurred.
964292
public void scanClass(InputStream bits) throws IOException
    {
        DataInputStream dstream = new DataInputStream(new BufferedInputStream(bits));
        ClassFile cf = null;
        try
        {
            cf = new ClassFile(dstream);

            String className = cf.getName();
            List<String> annotations = new ArrayList<String>();

            accumulateAnnotations(annotations, (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag));
            accumulateAnnotations(annotations,
                    (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.invisibleTag));

            // iterate through all valid annotations
            for (String validAnn : getValidAnnotations())
            {
                // check if the current class has one?
                if (annotations.contains(validAnn))
                {
                    // fire all listeners
                    for (AnnotationDiscoveryListener listener : getAnnotationDiscoveryListeners())
                    {
                        listener.discovered(className);
                    }
                }
            }

        }
        finally
        {
            dstream.close();
            bits.close();
        }
    }
1218457
@Override
  public int read() throws IOException {
    try {
      beforeRead(1);
      int c = in.read();
      afterRead(c != -1 ? 1 : -1);
      return c;
    } catch (IOException e) {
      handleIOException(e);
      return -1;
    }
  }
1132128
@Override
  public synchronized void mark(int idx) throws IOException {
    try {
      in.mark(idx);
    } catch (IOException e) {
      handleIOException(e);
    }
  }
1349387
public static <T extends BitReadable> T readObject(final BitInput input, final Class<T> type) throws IOException {
        if (input == null) {
            throw new NullPointerException("input is null");
        }
        if (type == null) {
            throw new NullPointerException("type is null");
        }
        try {
            final Constructor<T> constructor = type.getDeclaredConstructor();
            if (!constructor.isSynthetic()) {
                constructor.setAccessible(true);
            }
            try {
                final T value = constructor.newInstance();
                value.read(input);
                return value;
            } catch (final IllegalAccessException iae) {
                throw new RuntimeException(iae);
            } catch (final InstantiationException ie) {
                throw new RuntimeException(ie);
            } catch (final InvocationTargetException ite) {
                throw new RuntimeException(ite);
            }
        } catch (final NoSuchMethodException nsme) {
            throw new RuntimeException(nsme);
        }
    }
752563
public Bits read(final int bits) throws IOException {
    final int additionalBitsNeeded = bits - this.remainder.bitLength;
    final int additionalBytesNeeded = (int) Math.ceil(additionalBitsNeeded / 8.);
    if (additionalBytesNeeded > 0) this.readAhead(additionalBytesNeeded);
    final Bits readBits = this.remainder.range(0, bits);
    this.remainder = this.remainder.range(bits);
    return readBits;
  }
284363
private void scan(final char[] input, final int start, final int end)
	{

		this.positions = new HashMap<Character, ArrayList<Integer>>();
		ArrayList<Integer> list;

		char c;
		for (int i = start; i < end; i++) {
			c = input[i];

			list = positions.get(c);
			if (list == null) {
				list = new ArrayList<Integer>();
				positions.put(c, list);
			}

			list.add(i);
		}
	}
1037379
public void writeZeroes(int bits) throws IOException {
        if (bits == 0) return;
        if (!ensureSize(bits)) throw new IOException("Memory Allocation Error");
        totalBits += bits;
        while (bits > 0) {
            int n = Math.min(BITS_PER_BLURB - outBits, bits);
            buffer[outBlurbs] <<= n;
            bits -= n;
            outBits += n;
            if (outBits == BITS_PER_BLURB) {
                outBlurbs++;
                outBits = 0;
            }
        }
    }
694500
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException
    {
        s.defaultReadObject();
        Throwable cause = super.getCause();
        if (!(cause instanceof IOException))
            throw new InvalidObjectException("Cause must be an IOException");
    }
985010
public void expect(final Bits bits) throws IOException {
    int size = Math.min(availible(), bits.bitLength);
    Bits read = read(size);
    if (!bits.range(0, size).equals(read)) {
      throw new RuntimeException(String.format("%s is not expected %s", read, bits));
    }
  }
239003
private static void check(byte[] encoding) throws IOException {
        int length = encoding.length;
        if (length < 1 ||      // too short
                (encoding[length - 1] & 0x80) != 0) {  // not ended
            throw new IOException("ObjectIdentifier() -- " +
                    "Invalid DER encoding, not ended");
        }
        for (int i=0; i<length; i++) {
            // 0x80 at the beginning of a subidentifier
            if (encoding[i] == (byte)0x80 &&
                    (i==0 || (encoding[i-1] & 0x80) == 0)) {
                throw new IOException("ObjectIdentifier() -- " +
                        "Invalid DER encoding, useless extra octet detected");
            }
        }
    }
1062258
@Override
    public void scan(ClassSource_Aggregate classSource, Set<String> specificClassNames) throws AnnotationTargets_Exception {
        try {
            createScanner(classSource).scan(specificClassNames);
            // 'createScanner' throws class source exception

        } finally {
            haveScannedDirectClasses = true;
            haveScannedReferencedClasses = true;
        }
    }
300263
public static void scanner(Class<?> implementObjectClass, Class<?>... proxyClass) {

        if (AopCache.isScannedClass(implementObjectClass)) {
            return;
        }
        Method[] methods = ReflectUtil.getAllMethod(implementObjectClass);

        if (methods != null) {

            AopConfig config = null;
            Before before = null;
            After after = null;
            Class<?>[] argsType;

            for (Method method : methods) {

                config = new AopConfig();
                argsType = method.getParameterTypes();

                if (argsType != null && argsType.length > 0) {
                    for (Class<?> clazz : argsType) {
                        config.setArgs(clazz.getName());
                    }
                }

                before = method.getAnnotation(Before.class);
                after = method.getAnnotation(After.class);

                config.setMethodName(method.getName());
                if (proxyClass != null && proxyClass.length > 0) {
                    config.setClassPath(proxyClass[0].getName());
                } else {
                    config.setClassPath(implementObjectClass.getName());
                }

                if (before == null && after == null) {
                    config.setUsedAop(false);
                } else {
                    config.setUsedAop(true);
                    if (before != null) {
                        config.setBefore(before);
                        try {
                            Object instance = AopCache.getCutPoint(before.cutClass());
                            if (instance != null) {
                                config.setBeforeInstance(instance);
                            } else {
                                instance = before.cutClass().newInstance();
                                config.setBeforeInstance(instance);
                                AopCache.putCutPoint(instance);
                            }
                        } catch (InstantiationException e) {
                            e.printStackTrace();
                        } catch (IllegalAccessException e) {
                            e.printStackTrace();
                        }
                    }
                    if (after != null) {
                        config.setAfter(after);
                        try {
                            Object instance = AopCache.getCutPoint(after.cutClass());
                            if (instance != null) {
                                config.setAfterInstance(instance);
                            } else {
                                instance = after.cutClass().newInstance();
                                config.setAfterInstance(instance);
                                AopCache.putCutPoint(instance);
                            }
                        } catch (InstantiationException e) {
                            e.printStackTrace();
                        } catch (IllegalAccessException e) {
                            e.printStackTrace();
                        }
                    }
                }

                AopCache.putAopConfig(config);
            }
        }
    }
1077892
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            branchTargets = new BitSet();
            catchTargets = new BitSet();
            stack = new OpcodeStack();
            super.visitClassContext(classContext);
        } finally {
            branchTargets = null;
            catchTargets = null;
            stack = null;
        }
    }
727975
private static long scanForSequence(final ImageInputStream pStream, final byte[] pSequence) throws IOException {
        long start = -1l;

        int index = 0;
        int nullBytes = 0;

        for (int read; (read = pStream.read()) >= 0;) {
            if (pSequence[index] == (byte) read) {
                // If this is the first byte in the sequence, store position
                if (start == -1) {
                    start = pStream.getStreamPosition() - 1;
                }

                // Inside the sequence, there might be 1 or 3 null bytes, depending on 16/32 byte encoding
                if (nullBytes == 1 || nullBytes == 3) {
                    pStream.skipBytes(nullBytes);
                }

                index++;

                // If we found the entire sequence, we're done, return start position
                if (index == pSequence.length) {
                    return start;
                }
            }
            else if (index == 1 && read == 0 && nullBytes < 3) {
                // Skip 1 or 3 null bytes for 16/32 bit encoding
                nullBytes++;
            }
            else if (index != 0) {
                // Start over
                index = 0;
                start = -1;
                nullBytes = 0;
            }
        }

        return -1l;
    }
684356
public int readBit() throws IOException, JPEGMarkerException {
        int bit = 0;

        if (cnt == 0) {
            b = in.read();
            cnt = 8;

            if (b == 0xFF) {
                // Loop here to discard any padding FF's on terminating marker
                do {
                    b = in.read();
                } while (b == 0xFF);

                if (b == 0) {
                    /* Found FF/00, which represents an FF data byte */
                    b = 0xFF;
                    cnt = 8;
                } else {
                    throw new JPEGMarkerException(b);
                }
            } else if (b == -1) {
                throw new JPEGMarkerException(b);
            }
        }

        bit = b >> 7;
        cnt--;
        b = b << 1;

        return bit & 0x1;
    }
1302915
@Override
	public void flipBit(int index) {
		index = adjIndex(index);
		checkMutable();
		final int i = index >> ADDRESS_BITS;
		final long m = 1L << (index & ADDRESS_MASK);
		bits[i] ^=  m;
	}
127641
public static void clear(long[] bits, int pos) {
    int offset = pos >> LONG_SHIFT;
    if (offset >= bits.length)
      throw new IndexOutOfBoundsException();
    bits[offset] &= ~(1L << pos);
  }