コード例 #1
0
ファイル: Main.java プロジェクト: Daemonceltics/Dalvik-VM
  static void b2487514Test() {
    PriorityBlockingQueue q = new PriorityBlockingQueue(10);
    int catchCount = 0;

    q.offer(new Integer(0));
    /*
     * Warm up the code cache to have toArray() compiled. The key here is
     * to pass a compatible type so that there are no exceptions when
     * executing the method body (ie the APUT_OBJECT bytecode).
     */
    for (int i = 0; i < 1000; i++) {
      Integer[] ints = (Integer[]) q.toArray(new Integer[5]);
    }

    /* Now pass an incompatible type which is guaranteed to throw */
    for (int i = 0; i < 1000; i++) {
      try {
        Object[] obj = q.toArray(new String[5]);
      } catch (ArrayStoreException success) {
        catchCount++;
      }
    }

    if (catchCount == 1000) {
      System.out.println("b2487514 passes");
    } else {
      System.out.println("b2487514 fails: catchCount is " + catchCount + " (expecting 1000)");
    }
  }
コード例 #2
0
ファイル: ImagePanel.java プロジェクト: nbbrooks/sami-crw
  public static void addImage(BufferedImage img, UtmPose pose) {

    if (imagesDir != null) {
      try {
        File outputfile =
            new File(
                imagesDir.getAbsolutePath() + File.separator + "BoatImg" + (new Date()) + ".png");
        System.out.println("Writing to " + outputfile + " " + pose);
        ImageIO.write(img, "png", outputfile);
      } catch (IOException e) {
        System.out.println("Failed to write image to file: " + e);
      }
    } else {
      System.out.println("Do not know where to save images");
    }

    if (queue.size() > 100) {
      int v = rateS.getValue();
      int nv = Math.min(100, Math.max(v, (rateS.getValue() / 10)));
      if (v != nv) {
        rateS.setValue(nv);
      }
    }

    if (queue.size() < 1000) {
      queue.offer(new BufferedImageWithPose(img, pose));
      queueP.setValue(Math.min(100, queue.size()));
    } else {
      System.out.println("No longer queuing images, queue is full");
    }
  }
コード例 #3
0
ファイル: AbstractModule.java プロジェクト: nexcra/bittella
 public void enqueue(EventHandler h) {
   handlersQueue.offer(h);
 }