code: public Matcher usePattern(Pattern newPattern) {
          if (newPattern == null) {
              throw new IllegalArgumentException("newPattern == null");
          }
  
          this.pattern = newPattern;
  
          /* J2ObjC removed.
          synchronized (this) {
              if (nativeFinalizer != null) {
                  nativeFinalizer.run();
                  address = 0; // In case openImpl throws.
                  nativeFinalizer = null;
              }
              address = openImpl(pattern.address);
              nativeFinalizer = registry.registerNativeAllocation(this, address);
          }
          */
          if (address != 0) {
              closeImpl(address);
              address = 0;
          }
          address = openImpl(pattern.address);
  
          if (input != null) {
              resetForInput();
          }
  
          matchOffsets = new int[(groupCount() + 1) * 2];
          matchFound = false;
          return this;
      }
docs: Changes the <tt>Pattern</tt> that this <tt>Matcher</tt> uses to
  find matches with.
  
  <p> This method causes this matcher to lose information
  about the groups of the last match that occurred. The
  matcher's position in the input is maintained and its
  last append position is unaffected.</p>
  
  @param  newPattern
  The new pattern used by this matcher
  @return  This matcher
  @throws  IllegalArgumentException
  If newPattern is <tt>null</tt>
  @since 1.5