void lazyCopy(JSMessageData original) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            JmfTr.entry(this, tc, "lazyCopy", new Object[] { original });

        synchronized (getMessageLockArtefact()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                JmfTr.debug(this, tc, "lazyCopy locked dest ", new Object[] { getMessageLockArtefact() });

            // This is the only occasion that we reach out and lock another message instance
            // but we work on the assumption that lazy copying is happening as part of
            // instantiation of a new message instance, so the potential for deadlocking
            // is nil, since no other thread knows about this instance and can not therefore
            // be concurrently supplying 'this' as the 'original' argument in another thread.
            synchronized (original.getMessageLockArtefact()) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    JmfTr.debug(this, tc, "lazyCopy locked source ", new Object[] { original.getMessageLockArtefact() });

                // Copy common fields
                indirect = original.indirect;

                // If the message is assembled (i.e. we have a contents buffer) we share both the
                // buffer and the cache between original and copy.
                // If the message is unassembled (no contents buffer) we just share the cache.
                // In either case if a change later needs to be made to the shared portion we
                // will need to copy it before changing, so the shared flags is set to
                // indicate sharing exists between unrelated parts.
                if (original.contents == null) {
                    contents = null;
                    original.sharedCache = true;
                    sharedCache = true;
                    cache = original.cache;
                }
                else {
                    original.sharedContents = true;
                    sharedContents = true;
                    contents = original.contents;
                    original.sharedCache = true;
                    sharedCache = true;
                    cache = original.cache;
                }

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    JmfTr.debug(this, tc, "lazyCopy unlocking source ", new Object[] { original.getMessageLockArtefact() });
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                JmfTr.debug(this, tc, "lazyCopy unlocking dest ", new Object[] { getMessageLockArtefact() });
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            JmfTr.exit(this, tc, "lazyCopy");
    }
void lazyCopy ( JSMessageData original ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) JmfTr . entry ( this , tc , "lazyCopy" , new Object [ ] { original } ) ; synchronized ( getMessageLockArtefact ( ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) JmfTr . debug ( this , tc , "lazyCopy locked dest " , new Object [ ] { getMessageLockArtefact ( ) } ) ; synchronized ( original . getMessageLockArtefact ( ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) JmfTr . debug ( this , tc , "lazyCopy locked source " , new Object [ ] { original . getMessageLockArtefact ( ) } ) ; indirect = original . indirect ; if ( original . contents == null ) { contents = null ; original . sharedCache = true ; sharedCache = true ; cache = original . cache ; } else { original . sharedContents = true ; sharedContents = true ; contents = original . contents ; original . sharedCache = true ; sharedCache = true ; cache = original . cache ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) JmfTr . debug ( this , tc , "lazyCopy unlocking source " , new Object [ ] { original . getMessageLockArtefact ( ) } ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) JmfTr . debug ( this , tc , "lazyCopy unlocking dest " , new Object [ ] { getMessageLockArtefact ( ) } ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) JmfTr . exit ( this , tc , "lazyCopy" ) ; }
setting up the sharing state.