package com.siyeh.igtest.threading.call_to_native_method_while_locked;

public class CallToNativeMethodWhileLocked {

  synchronized void a() {
    Double.<warning descr="Call to native method 'doubleToRawLongBits()' in a synchronized context">doubleToRawLongBits</warning>(9.7);
    Runnable r = () -> {
      Double.doubleToRawLongBits(123.4);
    };
    new Object() {
      long l = Double.doubleToRawLongBits(42.0);

      synchronized void x() {
        <warning descr="Call to native method 'y()' in a synchronized context">y</warning>();
      }

      native void y();
    };
    Runnable s = () -> {
      assert Thread.holdsLock(this);
      Double.<warning descr="Call to native method 'doubleToRawLongBits()' in a synchronized context">doubleToRawLongBits</warning>(40.0);
    };
  }

  void test(String[] src, String[] target) {
    synchronized (this) {
      System.arraycopy(src, 0, target, 1, 5);
      System.out.println(System.identityHashCode(src));
    }
  }
}
