if oldMc is null, newMc will replace whatever meta class was used before.
if oldMc is not null, then newMc will be used only if he stored mc is
the same as oldMc
187315
private void setMetaClass(Class theClass, MetaClass oldMc, MetaClass newMc) {
        final ClassInfo info = ClassInfo.getClassInfo(theClass);
        
        MetaClass mc = null;
        info.lock();
        try {
            mc = info.getStrongMetaClass();
            info.setStrongMetaClass(newMc);
        } finally {
            info.unlock();
        }
        if ((oldMc == null && mc != newMc) || (oldMc != null && mc != newMc && mc != oldMc)) {
            fireConstantMetaClassUpdate(null, theClass, mc, newMc);
        }
    }
322559
@Override
  public boolean isModified()
  {
    if (_isDigestModified) {
      if (log.isLoggable(Level.FINE))
        log.fine(_source.getNativePath() + " digest is modified.");

      return true;
    }

    long sourceLastModified = _source.getLastModified();
    long sourceLength = _source.length();
    
    // if the source was deleted and we need the source
    if (! _requireSource && sourceLastModified == 0) {
      return false;
    }
    // if the length changed
    else if (sourceLength != _length) {
      if (log.isLoggable(Level.FINE)) {
        log.fine(_source.getNativePath() + " length is modified (" +
                 _length + " -> " + sourceLength + ")");
      }

      return true;
    }
    // if the source is newer than the old value
    else if (sourceLastModified != _lastModified) {
      if (log.isLoggable(Level.FINE))
        log.fine(_source.getNativePath() + " time is modified.");
      
      return true;
    }
    else
      return false;
  }
99804
function(cb) {
        if (process.env.FLVMETA_PATH) {
          fs.exists(process.env.FLVMETA_PATH, function(exists) {
            cb(null, exists ? process.env.FLVMETA_PATH : '');
          });
        } else {
          cb(null, '');
        }
      }
1352516
public boolean replaceChild(AbstractPlanNode oldChild, AbstractPlanNode newChild) {
        assert(oldChild != null);
        assert(newChild != null);
        int idx = 0;
        for (AbstractPlanNode child : m_children) {
            if (child.equals(oldChild)) {
                oldChild.m_parents.clear();
                setAndLinkChild(idx, newChild);
                return true;
            }
            ++idx;
        }
        return false;
    }
1214172
public boolean metadataEquals(Map<String, byte[]> otherMetadata) {
    if (metadata == otherMetadata) {
      // Fast-path for common cases where the same actual default metadata instance may be used in
      // multiple different item infos.
      return true;
    }
    // No need to check if other `metadata` is not null,
    // because previous `if` checks if both of them are null.
    if (metadata == null || otherMetadata == null) {
      return false;
    }
    if (!metadata.keySet().equals(otherMetadata.keySet())) {
      return false;
    }

    // Compare each byte[] with Arrays.equals.
    for (Map.Entry<String, byte[]> metadataEntry : metadata.entrySet()) {
      if (!Arrays.equals(metadataEntry.getValue(), otherMetadata.get(metadataEntry.getKey()))) {
        return false;
      }
    }
    return true;
  }
549077
def has_metaclass(parent):
    
    for node in parent.children:
        if node.type == syms.suite:
            return has_metaclass(node)
        elif node.type == syms.simple_stmt and node.children:
            expr_node = node.children[0]
            if expr_node.type == syms.expr_stmt and expr_node.children:
                left_side = expr_node.children[0]
                if isinstance(left_side, Leaf) and \
                        left_side.value == '__metaclass__':
                    return True
    return False
991097
boolean updateIndexEntry(S userStorable, S oldUserStorable) throws PersistException {
        Storable newIndexEntry = makeIndexEntry(userStorable);

        if (oldUserStorable != null) deleteOldEntry: {
            Storable oldIndexEntry;
            try {
                oldIndexEntry = makeIndexEntry(oldUserStorable);
            } catch (PersistException e) {
                Throwable cause = e.getCause();
                if (cause instanceof IllegalArgumentException) {
                    // Can be caused by a corrupt master record, which is
                    // attempting do assign an illegal value to the index. There's
                    // no way to find the old index entry to delete.
                    break deleteOldEntry;
                }
                throw e;
            }

            if (oldIndexEntry.equalPrimaryKeys(newIndexEntry)) {
                // Index entry didn't change, so nothing to do. If the index
                // entry has a version, it will lag behind the master's version
                // until the index entry changes, at which point the version
                // will again match the master.
                return true;
            }

            oldIndexEntry.tryDelete();
        }

        return insertIndexEntry(userStorable, newIndexEntry);
    }
31638
public boolean replaceRef(Object oldRef, Object newRef)
        throws IOException
    {
        Integer value = (Integer) _refs.remove(oldRef);

        if (value != null) {
            _refs.put(newRef, value);

            return true;
        }
        else
            return false;
    }
346363
protected function clean( $meta = null ) {

    //
    if( $meta && !( $meta instanceof StorageMeta ) ) {
      $meta = $this->getMeta( $meta );
    }

    // clear the cache
    if( !$meta || empty( $meta->token ) ) $this->cache = [];
    else foreach( $this->cache as $i => $_ ) {

      if( empty( $i ) || $i == $meta->token[ 0 ] || strpos( $i, $meta->token[ 0 ] ) === 0 ) {
        unset( $this->cache[ $i ] );
      }
    }
  }
600553
public static void setMetaClass(Class self, MetaClass metaClass) {
        final MetaClassRegistry metaClassRegistry = GroovySystem.getMetaClassRegistry();
        if (metaClass == null)
            metaClassRegistry.removeMetaClass(self);
        else {
            if (metaClass instanceof HandleMetaClass) {
                metaClassRegistry.setMetaClass(self, ((HandleMetaClass)metaClass).getAdaptee());
            } else {
                metaClassRegistry.setMetaClass(self, metaClass);
            }
            if (self==NullObject.class) {
                NullObject.getNullObject().setMetaClass(metaClass);
            }
        }
    }
827440
private boolean markAsObsolete(ContentReference ref) {
        if (obsoleteContents.containsKey(ref.getHexHash())) { //This content is already marked as obsolete
            if (obsoleteContents.get(ref.getHexHash()) + obsolescenceTimeout < System.currentTimeMillis()) {
                DeploymentRepositoryLogger.ROOT_LOGGER.obsoleteContentCleaned(ref.getContentIdentifier());
                removeContent(ref);
                return true;
            }
        } else {
            obsoleteContents.put(ref.getHexHash(), System.currentTimeMillis()); //Mark content as obsolete
        }
        return false;
    }
1002218
public void
apply(Message m, TSIGRecord old) {
	apply(m, Rcode.NOERROR, old);
}
594306
public void sessionAttributeRemoved(ISession source, Object key, Object value, Boolean oldIsBindingListener) {
        // ArrayList sessionStateObservers = null;

        /*
         * Check to see if there is a non-empty list of sessionStateObservers.
         */
        if (_sessionStateObservers == null || _sessionStateObservers.size() < 1) {
            return;
        }

        // synchronized(_sessionStateObservers) {
        // sessionStateObservers = (ArrayList)_sessionStateObservers.clone();
        // }

        ISessionStateObserver sessionStateObserver = null;
        for (int i = 0; i < _sessionStateObservers.size(); i++) {
            sessionStateObserver = (ISessionStateObserver) _sessionStateObservers.get(i);
            sessionStateObserver.sessionAttributeRemoved(source, key, value, oldIsBindingListener);
        }

    }
63688
private void diffRecursively(CatalogType prevType, CatalogType newType)
    {
        assert(prevType != null) : "Null previous object found in catalog diff traversal.";
        assert(newType != null) : "Null new object found in catalog diff traversal";

        Object materializerValue = null;
        // Consider shifting into the strict more required within materialized view definitions.
        if (prevType instanceof Table) {
            // Under normal circumstances, it's highly unlikely that another (nested?) table will
            // appear in the details of a materialized view table. So, when it does (!?), be sure to
            // complain -- and don't let it throw off the accounting of the strict diff mode.
            // That is, don't set the local "materializerValue".
            if (m_inStrictMatViewDiffMode) {
                // Maybe this should log or append to m_errors?
                System.out.println("ERROR: unexpected nesting of a Table in CatalogDiffEngine.");
            } else {
                materializerValue = prevType.getField("materializer");
                if (materializerValue != null) {
                    // This table is a materialized view, so the changes to it and its children are
                    // strictly limited, e.g. no adding/dropping columns.
                    // In a future development, such changes may be allowed, but they may be implemented
                    // differently (get different catalog commands), such as through a wholesale drop/add
                    // of the entire view and materialized table definitions.
                    // The non-null local "materializerValue" is a reminder to pop out of this mode
                    // before returning from this level of the recursion.
                    m_inStrictMatViewDiffMode = true;
                    if (m_triggeredVerbosity) {
                        System.out.println("DEBUG VERBOSE diffRecursively entering strict mat view mode");
                    }
                }
            }
        }

        // diff local fields
        for (String field : prevType.getFields()) {
            // this field is (or was) set at runtime, so ignore it for diff purposes
            if (field.equals("isUp"))
            {
                continue;
            }

            boolean verbosityTriggeredHere = false;
            if (( ! m_triggeredVerbosity) && field.equals(m_triggerForVerbosity)) {
                System.out.println("DEBUG VERBOSE diffRecursively verbosity (triggered by field '" + field + "' is ON");
                verbosityTriggeredHere = true;
                m_triggeredVerbosity = true;
            }
            // check if the types are different
            // options are: both null => same
            //              one null and one not => different
            //              both not null => check Object.equals()
            Object prevValue = prevType.getField(field);
            Object newValue = newType.getField(field);
            if ((prevValue == null) != (newValue == null)) {
                if (m_triggeredVerbosity) {
                    if (prevValue == null) {
                        System.out.println("DEBUG VERBOSE diffRecursively found new '" + field + "' only.");
                    } else {
                        System.out.println("DEBUG VERBOSE diffRecursively found prev '" + field + "' only.");
                    }
                }
                writeModification(newType, prevType, field);
            }
            // if they're both not null (above/below ifs implies this)
            else if (prevValue != null) {
                // if comparing CatalogTypes (both must be same)
                if (prevValue instanceof CatalogType) {
                    assert(newValue instanceof CatalogType);
                    String prevPath = ((CatalogType) prevValue).getCatalogPath();
                    String newPath = ((CatalogType) newValue).getCatalogPath();
                    if (prevPath.compareTo(newPath) != 0) {
                        if (m_triggeredVerbosity) {
                            int padWidth = StringUtils.indexOfDifference(prevPath, newPath);
                            String pad = StringUtils.repeat(" ", padWidth);
                            System.out.println("DEBUG VERBOSE diffRecursively found a path change to '" + field + "':");
                            System.out.println("DEBUG VERBOSE prevPath=" + prevPath);
                            System.out.println("DEBUG VERBOSE diff at->" + pad + "^ position:" + padWidth);
                            System.out.println("DEBUG VERBOSE  newPath=" + newPath);
                        }
                        writeModification(newType, prevType, field);
                    }
                }
                // if scalar types
                else {
                    if (prevValue.equals(newValue) == false) {
                        if (m_triggeredVerbosity) {
                            System.out.println("DEBUG VERBOSE diffRecursively found a scalar change to '" + field + "':");
                            System.out.println("DEBUG VERBOSE diffRecursively prev: " + prevValue);
                            System.out.println("DEBUG VERBOSE diffRecursively new : " + newValue);
                            if (field.equals("plannodetree")) {
                                try {
                                    System.out.println("DEBUG VERBOSE where prev plannodetree expands to: " +
                                            new String(CompressionService.decodeBase64AndDecompressToBytes((String)prevValue), "UTF-8"));
                                }
                                catch (Exception e) {
                                    try {
                                        System.out.println("DEBUG VERBOSE where prev plannodetree expands to: " +
                                                new String(Encoder.decodeBase64AndDecompressToBytes((String)prevValue), "UTF-8"));
                                    }
                                    catch (UnsupportedEncodingException e2) {}
                                }
                                try {
                                    System.out.println("DEBUG VERBOSE where new plannodetree expands to: " +
                                            new String(CompressionService.decodeBase64AndDecompressToBytes((String)newValue), "UTF-8"));
                                }
                                catch (Exception e) {
                                    try {
                                        System.out.println("DEBUG VERBOSE where new plannodetree expands to: " +
                                                new String(Encoder.decodeBase64AndDecompressToBytes((String)newValue), "UTF-8"));
                                    }
                                    catch (UnsupportedEncodingException e2) {}
                                }
                            }
                        }
                        writeModification(newType, prevType, field);
                    }
                }
            }
            if (verbosityTriggeredHere) {
                System.out.println("DEBUG VERBOSE diffRecursively verbosity is OFF");
                m_triggeredVerbosity = false;
            }
        }

        // recurse
        for (String field : prevType.getChildCollections()) {
            boolean verbosityTriggeredHere = false;
            if (field.equals(m_triggerForVerbosity)) {
                System.out.println("DEBUG VERBOSE diffRecursively verbosity ON");
                m_triggeredVerbosity = true;
                verbosityTriggeredHere = true;
            }
            CatalogMap<? extends CatalogType> prevMap = prevType.getCollection(field);
            CatalogMap<? extends CatalogType> newMap = newType.getCollection(field);
            getCommandsToDiff(field, prevMap, newMap);
            if (verbosityTriggeredHere) {
                System.out.println("DEBUG VERBOSE diffRecursively verbosity OFF");
                m_triggeredVerbosity = false;
            }
        }

        if (materializerValue != null) {
            // Just getting back from recursing into a materialized view table,
            // so drop the strictness required only in that context.
            // It's safe to assume that the prior mode to which this must pop back is the non-strict
            // mode because nesting of table definitions is unpossible AND we guarded against its
            // potential side effects, above, anyway.
            m_inStrictMatViewDiffMode = false;
        }

    }
858900
@Nonnull
    public static List<MavenArtifact> isSameCause(MavenDependencyCause newMavenCause, Cause oldMavenCause) {
        if (!(oldMavenCause instanceof MavenDependencyCause)) {
            return Collections.emptyList();
        }

        List<MavenArtifact> newCauseArtifacts = Preconditions.checkNotNull(newMavenCause.getMavenArtifacts(), "newMavenCause.mavenArtifacts should not be null");
        List<MavenArtifact> oldCauseArtifacts =  Preconditions.checkNotNull(((MavenDependencyCause) oldMavenCause).getMavenArtifacts(), "oldMavenCause.mavenArtifacts should not be null");

        List<MavenArtifact> matchingArtifacts = new ArrayList<>();
        for (MavenArtifact newCauseArtifact : newCauseArtifacts) {
            if (newCauseArtifact.isSnapshot() && newCauseArtifact.getVersion().contains("SNAPSHOT")) {
                // snapshot without exact version (aka base version), cannot search for same cause
            } else {
                for (MavenArtifact oldCauseArtifact : oldCauseArtifacts) {
                    if (Objects.equals(newCauseArtifact.getGroupId(), oldCauseArtifact.getGroupId()) &&
                            Objects.equals(newCauseArtifact.getArtifactId(), oldCauseArtifact.getArtifactId()) &&
                            Objects.equals(newCauseArtifact.getVersion(), oldCauseArtifact.getVersion()) &&
                            Objects.equals(newCauseArtifact.getBaseVersion(), oldCauseArtifact.getBaseVersion()) &&
                            Objects.equals(newCauseArtifact.getClassifier(), oldCauseArtifact.getClassifier()) &&
                            Objects.equals(newCauseArtifact.getType(), oldCauseArtifact.getType())) {
                        matchingArtifacts.add(newCauseArtifact);
                    }
                }
            }
        }

        return matchingArtifacts;
    }
1232338
void rebase(ContainerMetadata baseMetadata) {
        Preconditions.checkArgument(baseMetadata.getContainerId() == this.containerId, "ContainerId mismatch");
        Preconditions.checkArgument(baseMetadata.isRecoveryMode() == this.isRecoveryMode(), "isRecoveryMode mismatch");
        this.baseMetadata = baseMetadata;
        this.maximumActiveSegmentCount = baseMetadata.getMaximumActiveSegmentCount();
        this.baseNewSegmentCount = getNewSegmentCount(baseMetadata);
        resetNewSequenceNumber();
    }
90319
public static void updateMetadata(CacheEntry entry, Metadata providedMetadata) {
      if (entry != null && providedMetadata != null) {
         Metadata mergedMetadata;
         if (entry.getMetadata() == null) {
            mergedMetadata = providedMetadata;
         } else {
            mergedMetadata = applyVersion(entry.getMetadata(), providedMetadata);
         }
         entry.setMetadata(mergedMetadata);
      }
   }