rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
return KeyPairGeneratorFactory.getNames(); | if (names == null) { HashSet hs = new HashSet(); hs.add(Registry.DSS_KPG + "/" + Registry.RAW_ENCODING_SHORT_NAME); hs.add(Registry.DSS_KPG + "/" + Registry.X509_ENCODING_SORT_NAME); hs.add(Registry.DSS_KPG + "/" + Registry.PKCS8_ENCODING_SHORT_NAME); hs.add(Registry.RSA_KPG + "/" + Registry.RAW_ENCODING_SHORT_NAME); hs.add(Registry.RSA_KPG + "/" + Registry.X509_ENCODING_SORT_NAME); hs.add(Registry.RSA_KPG + "/" + Registry.PKCS8_ENCODING_SHORT_NAME); hs.add(Registry.DH_KPG + "/" + Registry.RAW_ENCODING_SHORT_NAME); hs.add(Registry.SRP_KPG + "/" + Registry.RAW_ENCODING_SHORT_NAME); names = Collections.unmodifiableSet(hs); } return names; | public static final Set getNames() { return KeyPairGeneratorFactory.getNames(); } |
return super.clone(); | BasePRNG result = (BasePRNG) super.clone(); if (this.buffer != null) result.buffer = (byte[])this.buffer.clone(); return result; | public Object clone() throws CloneNotSupportedException { return super.clone(); } |
checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field"); | DerUtil.checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field"); | public PublicKey decodePublicKey(byte[] input) { if (input == null) throw new InvalidParameterException("Input bytes MUST NOT be null"); BigInteger p, g, q, y; DERReader der = new DERReader(input); try { DERValue derSPKI = der.read(); checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field"); DERValue derAlgorithmID = der.read(); checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field"); DERValue derOID = der.read(); if (! (derOID.getValue() instanceof OID)) throw new InvalidParameterException("Wrong Algorithm field"); OID algOID = (OID) derOID.getValue(); if (! algOID.equals(DSA_ALG_OID)) throw new InvalidParameterException("Unexpected OID: " + algOID); DERValue derParams = der.read(); checkIsConstructed(derParams, "Wrong DSS Parameters field"); DERValue val = der.read(); checkIsBigInteger(val, "Wrong P field"); p = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong Q field"); q = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong G field"); g = (BigInteger) val.getValue(); val = der.read(); if (! (val.getValue() instanceof BitString)) throw new InvalidParameterException("Wrong SubjectPublicKey field"); byte[] yBytes = ((BitString) val.getValue()).toByteArray(); DERReader dsaPub = new DERReader(yBytes); val = dsaPub.read(); checkIsBigInteger(val, "Wrong Y field"); y = (BigInteger) val.getValue(); } catch (IOException x) { InvalidParameterException e = new InvalidParameterException(); e.initCause(x); throw e; } return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y); } |
checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field"); | DerUtil.checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field"); | public PublicKey decodePublicKey(byte[] input) { if (input == null) throw new InvalidParameterException("Input bytes MUST NOT be null"); BigInteger p, g, q, y; DERReader der = new DERReader(input); try { DERValue derSPKI = der.read(); checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field"); DERValue derAlgorithmID = der.read(); checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field"); DERValue derOID = der.read(); if (! (derOID.getValue() instanceof OID)) throw new InvalidParameterException("Wrong Algorithm field"); OID algOID = (OID) derOID.getValue(); if (! algOID.equals(DSA_ALG_OID)) throw new InvalidParameterException("Unexpected OID: " + algOID); DERValue derParams = der.read(); checkIsConstructed(derParams, "Wrong DSS Parameters field"); DERValue val = der.read(); checkIsBigInteger(val, "Wrong P field"); p = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong Q field"); q = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong G field"); g = (BigInteger) val.getValue(); val = der.read(); if (! (val.getValue() instanceof BitString)) throw new InvalidParameterException("Wrong SubjectPublicKey field"); byte[] yBytes = ((BitString) val.getValue()).toByteArray(); DERReader dsaPub = new DERReader(yBytes); val = dsaPub.read(); checkIsBigInteger(val, "Wrong Y field"); y = (BigInteger) val.getValue(); } catch (IOException x) { InvalidParameterException e = new InvalidParameterException(); e.initCause(x); throw e; } return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y); } |
checkIsConstructed(derParams, "Wrong DSS Parameters field"); | DerUtil.checkIsConstructed(derParams, "Wrong DSS Parameters field"); | public PublicKey decodePublicKey(byte[] input) { if (input == null) throw new InvalidParameterException("Input bytes MUST NOT be null"); BigInteger p, g, q, y; DERReader der = new DERReader(input); try { DERValue derSPKI = der.read(); checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field"); DERValue derAlgorithmID = der.read(); checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field"); DERValue derOID = der.read(); if (! (derOID.getValue() instanceof OID)) throw new InvalidParameterException("Wrong Algorithm field"); OID algOID = (OID) derOID.getValue(); if (! algOID.equals(DSA_ALG_OID)) throw new InvalidParameterException("Unexpected OID: " + algOID); DERValue derParams = der.read(); checkIsConstructed(derParams, "Wrong DSS Parameters field"); DERValue val = der.read(); checkIsBigInteger(val, "Wrong P field"); p = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong Q field"); q = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong G field"); g = (BigInteger) val.getValue(); val = der.read(); if (! (val.getValue() instanceof BitString)) throw new InvalidParameterException("Wrong SubjectPublicKey field"); byte[] yBytes = ((BitString) val.getValue()).toByteArray(); DERReader dsaPub = new DERReader(yBytes); val = dsaPub.read(); checkIsBigInteger(val, "Wrong Y field"); y = (BigInteger) val.getValue(); } catch (IOException x) { InvalidParameterException e = new InvalidParameterException(); e.initCause(x); throw e; } return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y); } |
checkIsBigInteger(val, "Wrong P field"); | DerUtil.checkIsBigInteger(val, "Wrong P field"); | public PublicKey decodePublicKey(byte[] input) { if (input == null) throw new InvalidParameterException("Input bytes MUST NOT be null"); BigInteger p, g, q, y; DERReader der = new DERReader(input); try { DERValue derSPKI = der.read(); checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field"); DERValue derAlgorithmID = der.read(); checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field"); DERValue derOID = der.read(); if (! (derOID.getValue() instanceof OID)) throw new InvalidParameterException("Wrong Algorithm field"); OID algOID = (OID) derOID.getValue(); if (! algOID.equals(DSA_ALG_OID)) throw new InvalidParameterException("Unexpected OID: " + algOID); DERValue derParams = der.read(); checkIsConstructed(derParams, "Wrong DSS Parameters field"); DERValue val = der.read(); checkIsBigInteger(val, "Wrong P field"); p = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong Q field"); q = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong G field"); g = (BigInteger) val.getValue(); val = der.read(); if (! (val.getValue() instanceof BitString)) throw new InvalidParameterException("Wrong SubjectPublicKey field"); byte[] yBytes = ((BitString) val.getValue()).toByteArray(); DERReader dsaPub = new DERReader(yBytes); val = dsaPub.read(); checkIsBigInteger(val, "Wrong Y field"); y = (BigInteger) val.getValue(); } catch (IOException x) { InvalidParameterException e = new InvalidParameterException(); e.initCause(x); throw e; } return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y); } |
checkIsBigInteger(val, "Wrong Q field"); | DerUtil.checkIsBigInteger(val, "Wrong Q field"); | public PublicKey decodePublicKey(byte[] input) { if (input == null) throw new InvalidParameterException("Input bytes MUST NOT be null"); BigInteger p, g, q, y; DERReader der = new DERReader(input); try { DERValue derSPKI = der.read(); checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field"); DERValue derAlgorithmID = der.read(); checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field"); DERValue derOID = der.read(); if (! (derOID.getValue() instanceof OID)) throw new InvalidParameterException("Wrong Algorithm field"); OID algOID = (OID) derOID.getValue(); if (! algOID.equals(DSA_ALG_OID)) throw new InvalidParameterException("Unexpected OID: " + algOID); DERValue derParams = der.read(); checkIsConstructed(derParams, "Wrong DSS Parameters field"); DERValue val = der.read(); checkIsBigInteger(val, "Wrong P field"); p = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong Q field"); q = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong G field"); g = (BigInteger) val.getValue(); val = der.read(); if (! (val.getValue() instanceof BitString)) throw new InvalidParameterException("Wrong SubjectPublicKey field"); byte[] yBytes = ((BitString) val.getValue()).toByteArray(); DERReader dsaPub = new DERReader(yBytes); val = dsaPub.read(); checkIsBigInteger(val, "Wrong Y field"); y = (BigInteger) val.getValue(); } catch (IOException x) { InvalidParameterException e = new InvalidParameterException(); e.initCause(x); throw e; } return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y); } |
checkIsBigInteger(val, "Wrong G field"); | DerUtil.checkIsBigInteger(val, "Wrong G field"); | public PublicKey decodePublicKey(byte[] input) { if (input == null) throw new InvalidParameterException("Input bytes MUST NOT be null"); BigInteger p, g, q, y; DERReader der = new DERReader(input); try { DERValue derSPKI = der.read(); checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field"); DERValue derAlgorithmID = der.read(); checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field"); DERValue derOID = der.read(); if (! (derOID.getValue() instanceof OID)) throw new InvalidParameterException("Wrong Algorithm field"); OID algOID = (OID) derOID.getValue(); if (! algOID.equals(DSA_ALG_OID)) throw new InvalidParameterException("Unexpected OID: " + algOID); DERValue derParams = der.read(); checkIsConstructed(derParams, "Wrong DSS Parameters field"); DERValue val = der.read(); checkIsBigInteger(val, "Wrong P field"); p = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong Q field"); q = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong G field"); g = (BigInteger) val.getValue(); val = der.read(); if (! (val.getValue() instanceof BitString)) throw new InvalidParameterException("Wrong SubjectPublicKey field"); byte[] yBytes = ((BitString) val.getValue()).toByteArray(); DERReader dsaPub = new DERReader(yBytes); val = dsaPub.read(); checkIsBigInteger(val, "Wrong Y field"); y = (BigInteger) val.getValue(); } catch (IOException x) { InvalidParameterException e = new InvalidParameterException(); e.initCause(x); throw e; } return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y); } |
checkIsBigInteger(val, "Wrong Y field"); | DerUtil.checkIsBigInteger(val, "Wrong Y field"); | public PublicKey decodePublicKey(byte[] input) { if (input == null) throw new InvalidParameterException("Input bytes MUST NOT be null"); BigInteger p, g, q, y; DERReader der = new DERReader(input); try { DERValue derSPKI = der.read(); checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field"); DERValue derAlgorithmID = der.read(); checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field"); DERValue derOID = der.read(); if (! (derOID.getValue() instanceof OID)) throw new InvalidParameterException("Wrong Algorithm field"); OID algOID = (OID) derOID.getValue(); if (! algOID.equals(DSA_ALG_OID)) throw new InvalidParameterException("Unexpected OID: " + algOID); DERValue derParams = der.read(); checkIsConstructed(derParams, "Wrong DSS Parameters field"); DERValue val = der.read(); checkIsBigInteger(val, "Wrong P field"); p = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong Q field"); q = (BigInteger) val.getValue(); val = der.read(); checkIsBigInteger(val, "Wrong G field"); g = (BigInteger) val.getValue(); val = der.read(); if (! (val.getValue() instanceof BitString)) throw new InvalidParameterException("Wrong SubjectPublicKey field"); byte[] yBytes = ((BitString) val.getValue()).toByteArray(); DERReader dsaPub = new DERReader(yBytes); val = dsaPub.read(); checkIsBigInteger(val, "Wrong Y field"); y = (BigInteger) val.getValue(); } catch (IOException x) { InvalidParameterException e = new InvalidParameterException(); e.initCause(x); throw e; } return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y); } |
String indentStr = ""; | StringBuffer b = new StringBuffer(); | public void dump(PrintStream stream, int indent) { String indentStr = ""; for (int i = 0; i < indent; ++i) indentStr += " "; dumpElement(stream, indentStr, this); } |
indentStr += " "; dumpElement(stream, indentStr, this); | b.append(' '); b.append('<'); b.append(getName()); if (getAttributeCount() > 0) { b.append('\n'); Enumeration attNames = getAttributeNames(); while (attNames.hasMoreElements()) { for (int i = 0; i < indent + 2; ++i) b.append(' '); Object attName = attNames.nextElement(); b.append(attName); b.append('='); Object attribute = getAttribute(attName); b.append(attribute); b.append('\n'); } } b.append(">\n"); if (isLeaf()) { for (int i = 0; i < indent + 2; ++i) b.append(' '); int start = getStartOffset(); int end = getEndOffset(); b.append('['); b.append(start); b.append(','); b.append(end); b.append("]["); try { b.append(getDocument().getText(start, end - start)); } catch (BadLocationException ex) { AssertionError err = new AssertionError("BadLocationException " + "must not be thrown " + "here."); err.initCause(ex); } b.append("]\n"); } stream.print(b.toString()); int count = getElementCount(); for (int i = 0; i < count; ++i) { Element el = getElement(i); if (el instanceof AbstractElement) ((AbstractElement) el).dump(stream, indent + 2); } | public void dump(PrintStream stream, int indent) { String indentStr = ""; for (int i = 0; i < indent; ++i) indentStr += " "; dumpElement(stream, indentStr, this); } |
protected Content getContent() { return content; } | protected final Content getContent() { return content; } | protected Content getContent() { return content; } |
this.currentUninterruptible = method.isUninterruptible(); | public void startMethod(VmMethod method) { this.currentMethod = method; this.currentKernelSpace = method.hasKernelSpacePragma(); super.startMethod(method); } |
|
if (currentKernelSpace) { | if (currentKernelSpace || currentUninterruptible) { | protected final void verifyInvoke(VmConstMethodRef methodRef) { if (currentKernelSpace) { // May only call methods with kernelspace pragma. methodRef.resolve(currentMethod.getDeclaringClass().getLoader()); final VmMethod callee = methodRef.getResolvedVmMethod(); if (!callee.hasKernelSpacePragma()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls method outside KernelSpace: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls method outside KernelSpace: " + callee.getFullName()); } if (callee.isSynchronized()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls synchronized method: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls synchronized method: " + callee.getFullName()); } } } |
if (!callee.hasKernelSpacePragma()) { System.out.println("Method '" + currentMethod.getFullName() + "' calls method outside KernelSpace: " + callee.getFullName()); | if (currentKernelSpace) { if (!callee.hasKernelSpacePragma()) { System.out.println("Method calls method outside KernelSpace:\n\tcaller: " + currentMethod.getFullName() + "\n\tcallee: " + callee.getFullName()); } } if (currentUninterruptible) { if (!callee.isUninterruptible()) { if (currentMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.schedule")) { System.out.println("Method calls interruptible method:\n\tcaller: " + currentMethod.getFullName() + "\n\tcallee: " + callee.getFullName()); } } | protected final void verifyInvoke(VmConstMethodRef methodRef) { if (currentKernelSpace) { // May only call methods with kernelspace pragma. methodRef.resolve(currentMethod.getDeclaringClass().getLoader()); final VmMethod callee = methodRef.getResolvedVmMethod(); if (!callee.hasKernelSpacePragma()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls method outside KernelSpace: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls method outside KernelSpace: " + callee.getFullName()); } if (callee.isSynchronized()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls synchronized method: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls synchronized method: " + callee.getFullName()); } } } |
selectedItem = getElementAt(selected - 1); | setSelectedItem(getElementAt(selected - 1)); | public void removeElementAt(int index) { int selected = getIndexOf(selectedItem); if (selected == index) // choose a new selected item { if (selected > 0) selectedItem = getElementAt(selected - 1); else selectedItem = getElementAt(selected + 1); } list.removeElementAt(index); fireIntervalRemoved(this, index, index); } |
selectedItem = getElementAt(selected + 1); | setSelectedItem(getElementAt(selected + 1)); | public void removeElementAt(int index) { int selected = getIndexOf(selectedItem); if (selected == index) // choose a new selected item { if (selected > 0) selectedItem = getElementAt(selected - 1); else selectedItem = getElementAt(selected + 1); } list.removeElementAt(index); fireIntervalRemoved(this, index, index); } |
final DoubleWordItem result = DoubleWordItem.createReg(jvmType, lsb, | final DoubleWordItem result = ifac.createReg(jvmType, lsb, | static final DoubleWordItem requestDoubleWordRegisters( EmitterContext eContext, int jvmType) { final X86RegisterPool pool = eContext.getPool(); final Register lsb = requestRegister(eContext, JvmType.INT, false); final Register msb = requestRegister(eContext, JvmType.INT, false); final DoubleWordItem result = DoubleWordItem.createReg(jvmType, lsb, msb); pool.transferOwnerTo(lsb, result); pool.transferOwnerTo(msb, result); return result; } |
final WordItem result = WordItem.createReg(jvmType, reg); | final WordItem result = ifac.createReg(jvmType, reg); | static final WordItem requestWordRegister(EmitterContext eContext, int jvmType, boolean supportsBits8) { final X86RegisterPool pool = eContext.getPool(); final Register reg = requestRegister(eContext, JvmType.INT, supportsBits8); final WordItem result = WordItem.createReg(jvmType, reg); pool.transferOwnerTo(reg, result); return result; } |
vsb.setValue(vr.y, vr.height, 0, vs.height); | vsb.setValues(vr.y, vr.height, 0, vs.height); | ChangeListener createScrollListener() { return new ChangeListener() { public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValue(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValue(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } } }; } |
hsb.setValue(vr.x, vr.width, 0, vs.width); | hsb.setValues(vr.x, vr.width, 0, vs.width); | ChangeListener createScrollListener() { return new ChangeListener() { public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValue(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValue(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } } }; } |
vsb.setValue(vr.y, vr.height, 0, vs.height); | vsb.setValues(vr.y, vr.height, 0, vs.height); | public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValue(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValue(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } } |
hsb.setValue(vr.x, vr.width, 0, vs.width); | hsb.setValues(vr.x, vr.width, 0, vs.width); | public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValue(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValue(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } } |
super(); | this.list = list; | public SwingListPeer(final List list) { super(); SwingToolkit.add(list, this); SwingToolkit.copyAwtProperties(list, this); final ListModel model = new AbstractListModel() { public int getSize() { return list.getItemCount(); } public Object getElementAt(int idx) { return list.getItem(idx); } }; } |
public int getSize() { return list.getItemCount(); } public Object getElementAt(int idx) { return list.getItem(idx); } }; | public Object getElementAt(int idx) { return list.getItem(idx); } public int getSize() { return list.getItemCount(); } }; | public SwingListPeer(final List list) { super(); SwingToolkit.add(list, this); SwingToolkit.copyAwtProperties(list, this); final ListModel model = new AbstractListModel() { public int getSize() { return list.getItemCount(); } public Object getElementAt(int idx) { return list.getItem(idx); } }; } |
public void addNodeChangeListener(NodeChangeListener listener) { | public void addNodeChangeListener(NodeChangeListener listener) { synchronized (lock) { if (isRemoved()) throw new IllegalStateException("node has been removed"); if (listener == null) throw new NullPointerException("listener is null"); if (nodeListeners == null) nodeListeners = new ArrayList(); nodeListeners.add(listener); } | public void addNodeChangeListener(NodeChangeListener listener) { // XXX } |
public void addPreferenceChangeListener(PreferenceChangeListener listener) { | public void addPreferenceChangeListener(PreferenceChangeListener listener) { synchronized (lock) { if (isRemoved()) throw new IllegalStateException("node has been removed"); if (listener == null) throw new NullPointerException("listener is null"); if (preferenceListeners == null) preferenceListeners = new ArrayList(); preferenceListeners.add(listener); } | public void addPreferenceChangeListener(PreferenceChangeListener listener) { // XXX } |
synchronized(this) { | synchronized(lock) { | private void flushNode(boolean sync) throws BackingStoreException { String[] keys = null; synchronized(lock) { if (sync) { syncSpi(); } else { flushSpi(); } keys = (String[]) childCache.keySet().toArray(new String[]{}); } if (keys != null) { for (int i = 0; i < keys.length; i++) { // Have to lock this node again to access the childCache AbstractPreferences subNode; synchronized(this) { subNode = (AbstractPreferences) childCache.get(keys[i]); } // The child could already have been removed from the cache if (subNode != null) { subNode.flushNode(sync); } } } } |
if (child.newNode && nodeListeners != null) fire(new NodeChangeEvent(this, child), true); | private Preferences getNode(String path) { // if mark is dom then goto end // Empty String "" indicates this node if (path.length() == 0) return this; // Calculate child name and rest of path String childName; String childPath; int nextSlash = path.indexOf('/'); if (nextSlash == -1) { childName = path; childPath = ""; } else { childName = path.substring(0, nextSlash); childPath = path.substring(nextSlash+1); } // Get the child node AbstractPreferences child; child = (AbstractPreferences)childCache.get(childName); if (child == null) { if (childName.length() > MAX_NAME_LENGTH) throw new IllegalArgumentException(childName); // Not in childCache yet so create a new sub node child = childSpi(childName); // XXX - check if node is new childCache.put(childName, child); } // Lock the child and go down synchronized(child.lock) { return child.getNode(childPath); } } |
|
synchronized(node) { | synchronized(node.lock) { | private void purge() throws BackingStoreException { // Make sure all children have an AbstractPreferences node in cache String children[] = childrenNamesSpi(); for (int i = 0; i < children.length; i++) { if (childCache.get(children[i]) == null) childCache.put(children[i], childSpi(children[i])); } // purge all children Iterator i = childCache.values().iterator(); while (i.hasNext()) { AbstractPreferences node = (AbstractPreferences) i.next(); synchronized(node) { node.purge(); } } // Cache is empty now childCache.clear(); // remove this node removeNodeSpi(); removed = true; // XXX - check for listeners } |
if (nodeListeners != null) fire(new NodeChangeEvent(parent, this), false); | private void purge() throws BackingStoreException { // Make sure all children have an AbstractPreferences node in cache String children[] = childrenNamesSpi(); for (int i = 0; i < children.length; i++) { if (childCache.get(children[i]) == null) childCache.put(children[i], childSpi(children[i])); } // purge all children Iterator i = childCache.values().iterator(); while (i.hasNext()) { AbstractPreferences node = (AbstractPreferences) i.next(); synchronized(node) { node.purge(); } } // Cache is empty now childCache.clear(); // remove this node removeNodeSpi(); removed = true; // XXX - check for listeners } |
|
if (preferenceListeners != null) fire(new PreferenceChangeEvent(this, key, value)); | public void put(String key, String value) { if (key.length() > MAX_KEY_LENGTH || value.length() > MAX_VALUE_LENGTH) throw new IllegalArgumentException("key (" + key.length() + ")" + " or value (" + value.length() + ")" + " to large"); synchronized(lock) { if (isRemoved()) throw new IllegalStateException("Node removed"); putSpi(key, value); // XXX - fire events } } |
|
put(key, String.valueOf(value)); | put(key, Boolean.toString(value)); | public void putBoolean(String key, boolean value) { put(key, String.valueOf(value)); // XXX - Use when using 1.4 compatible Boolean // put(key, Boolean.toString(value)); } |
if (preferenceListeners != null) fire(new PreferenceChangeEvent(this, key, null)); | public void remove(String key) { if (key.length() > MAX_KEY_LENGTH) throw new IllegalArgumentException(key); synchronized(lock) { if (isRemoved()) throw new IllegalStateException("Node removed"); removeSpi(key); } } |
|
synchronized(parent) { synchronized(this) { | synchronized (parent.lock) { synchronized(this.lock) { | public void removeNode() throws BackingStoreException { // Check if it is a root node if (parent == null) throw new UnsupportedOperationException("Cannot remove root node"); synchronized(parent) { synchronized(this) { if (isRemoved()) throw new IllegalStateException("Node Removed"); purge(); } parent.childCache.remove(name); } } |
public void removeNodeChangeListener(NodeChangeListener listener) { } | public void removeNodeChangeListener(NodeChangeListener listener) { synchronized (lock) { if (isRemoved()) throw new IllegalStateException("node has been removed"); if (listener == null) throw new NullPointerException("listener is null"); if (nodeListeners != null) nodeListeners.remove(listener); } } | public void removeNodeChangeListener(NodeChangeListener listener) { // XXX } |
} | synchronized (lock) { if (isRemoved()) throw new IllegalStateException("node has been removed"); if (listener == null) throw new NullPointerException("listener is null"); if (preferenceListeners != null) preferenceListeners.remove(listener); } } | public void removePreferenceChangeListener (PreferenceChangeListener listener) { // XXX } |
} else if (f.isAddressType()) { if (val == null) { } else if (val instanceof UnboxedObject) { final UnboxedObject uobj = (UnboxedObject)val; statics.setAddress(idx, uobj); } else if (val instanceof Label) { final Label lbl = (Label)val; statics.setAddress(idx, lbl); } else { throw new BuildException("Cannot handle magic type " + val.getClass().getName()); } | private void copyStaticField(VmType< ? > type, VmField f, Field jf, VmSharedStatics sharedStatics, VmIsolatedStatics isolatedStatics, NativeStream os, ObjectEmitter emitter) throws IllegalAccessException, JNodeClassNotFoundException { jf.setAccessible(true); final Object val = jf.get(null); final int fType = JvmType.SignatureToType(f.getSignature()); final int idx; final VmStaticField sf = (VmStaticField) f; final VmStatics statics; if (sf.isShared()) { idx = sf.getSharedStaticsIndex(); statics = sharedStatics; } else { idx = sf.getIsolatedStaticsIndex(); statics = isolatedStatics; } if (f.isPrimitive()) { if (f.isWide()) { final long lval; switch (fType) { case JvmType.LONG: lval = ((Long) val).longValue(); break; case JvmType.DOUBLE: lval = Double.doubleToRawLongBits(((Double) val) .doubleValue()); break; default: throw new IllegalArgumentException("Unknown wide type " + fType); } statics.setLong(idx, lval); } else { final int ival; final Class jfType = jf.getType(); if (jfType == boolean.class) { ival = ((Boolean) val).booleanValue() ? 1 : 0; } else if (jfType == byte.class) { ival = ((Byte) val).byteValue(); } else if (jfType == char.class) { ival = ((Character) val).charValue(); } else if (jfType == short.class) { ival = ((Short) val).shortValue(); } else if (jfType == int.class) { ival = ((Number) val).intValue(); } else if (jfType == float.class) { ival = Float.floatToRawIntBits(((Float) val).floatValue()); } else { throw new IllegalArgumentException("Unknown wide type " + fType); } statics.setInt(idx, ival); } } else { if (!Modifier.isAddressType(f.getSignature())) { if (val != null) { emitter.testForValidEmit(val, type.getName()); os.getObjectRef(val); } statics.setObject(idx, val); } } } |
|
public static boolean passEulerCriterion(final BigInteger w) { WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) | public static boolean passEulerCriterion(final BigInteger bn) | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; | BigInteger bn_minus_one = bn.subtract(ONE); BigInteger e = bn_minus_one; | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
BigInteger A; | BigInteger a; | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
if ((l & 7) != 0) | if (l != 0) | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
A = TWO.modPow(e, w); if ((l & 7) == 6) { if (A.bitCount() != 1) | a = TWO.modPow(e, bn); if (l == 6) | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
if (DEBUG && debuglevel > 4) | if (a.bitLength() != 1) | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
debug(w.toString(16) + " fails Euler criterion #1..."); } | debugBI("Fails Euler criterion #1", bn); | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
else { A = A.add(ONE); if (!A.equals(w)) | else | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
if (DEBUG && debuglevel > 4) | a = a.add(ONE); if (a.compareTo(bn) != 0) | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
debug(w.toString(16) + " fails Euler criterion #2..."); } | debugBI("Fails Euler criterion #2", bn); | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
A = TWO.modPow(e, w); if (A.bitCount() == 1) { | a = TWO.modPow(e, bn); if (a.bitLength() == 1) | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
} | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
|
A = A.add(ONE); if (!A.equals(w)) | a = a.add(ONE); if (a.compareTo(bn) != 0) | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } | debugBI("Fails Euler criterion #3", bn); | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
for (int i = j; i < 13; i++) { A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) | for (int i = j; i < 7; i++) | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
if (A.equals(w_minus_one)) { | if (a.compareTo(bn_minus_one) == 0) | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
} if (--l == 0) { if (DEBUG && debuglevel > 4) | if (--l == 0) | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
debug(w.toString(16) + " fails Euler criterion #4..."); } | debugBI("Fails Euler criterion #4", bn); | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
A = A.modPow(TWO, w); if (A.bitCount() == 1) | a = a.modPow(TWO, bn); if (a.bitLength() == 1) | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } | debugBI("Fails Euler criterion #5", bn); | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } knownPrimes.put(w, new WeakReference(w)); | debugBI("Passes Euler criterion", bn); | public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; } |
return new InliningBytecodeVisitor(entryPoints, cbv, loader); | return new OptimizingBytecodeVisitor(entryPoints, cbv, loader); | protected CompilerBytecodeVisitor createBytecodeVisitor(VmMethod method, CompiledMethod cm, NativeStream os, int level, boolean isBootstrap) { final InlineBytecodeVisitor cbv; final EntryPoints entryPoints = getEntryPoints(); cbv = new X86BytecodeVisitor(os, cm, isBootstrap, entryPoints, magicHelper, getTypeSizeInfo()); if (inlineMethods /*&& ((X86Assembler)os).isCode32()*/) { final VmClassLoader loader = method.getDeclaringClass().getLoader(); return new InliningBytecodeVisitor(entryPoints, cbv, loader); } else { return cbv; } } |
System.out.println(" Endi dragging "); | public void endDraggingFrame(JComponent f) {// super.endDraggingFrame(f); JInternalFrame frame = (JInternalFrame)f;// JDesktopPane desk = frame.getDesktopPane();// desk.repaint();// frame.validate();// frame.repaint(); ((Gui5250)frame.getContentPane()).getScreen().gg2d = null; System.out.println(" Endi dragging "); } |
|
setSize(300,300); | setSize(600,500); | public MyInternalFrame() { super("#" + (++openFrameCount), true, //resizable true, //closable true, //maximizable true);//iconifiable internalId = openFrameCount; //...Create the GUI and put it in the window... //...Then set the window size or call pack... setSize(300,300); //Set the window's location. setLocation(xOffset*openFrameCount, yOffset*openFrameCount); addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) {// displayMessage("Internal frame closing", e); disconnectMe(); } public void internalFrameClosed(InternalFrameEvent e) {// displayMessage("Internal frame closed", e); } public void internalFrameOpened(InternalFrameEvent e) {// displayMessage("Internal frame opened", e); } public void internalFrameIconified(InternalFrameEvent e) {// displayMessage("Internal frame iconified", e); } public void internalFrameDeiconified(InternalFrameEvent e) {// displayMessage("Internal frame deiconified", e); } public void internalFrameActivated(InternalFrameEvent e) {// displayMessage("Internal frame activated", e); activated = true; repaint(); } public void internalFrameDeactivated(InternalFrameEvent e) { activated = false; displayMessage("Internal frame deactivated", e); } }); } |
displayMessage("Internal frame deactivated", e); | public MyInternalFrame() { super("#" + (++openFrameCount), true, //resizable true, //closable true, //maximizable true);//iconifiable internalId = openFrameCount; //...Create the GUI and put it in the window... //...Then set the window size or call pack... setSize(300,300); //Set the window's location. setLocation(xOffset*openFrameCount, yOffset*openFrameCount); addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) {// displayMessage("Internal frame closing", e); disconnectMe(); } public void internalFrameClosed(InternalFrameEvent e) {// displayMessage("Internal frame closed", e); } public void internalFrameOpened(InternalFrameEvent e) {// displayMessage("Internal frame opened", e); } public void internalFrameIconified(InternalFrameEvent e) {// displayMessage("Internal frame iconified", e); } public void internalFrameDeiconified(InternalFrameEvent e) {// displayMessage("Internal frame deiconified", e); } public void internalFrameActivated(InternalFrameEvent e) {// displayMessage("Internal frame activated", e); activated = true; repaint(); } public void internalFrameDeactivated(InternalFrameEvent e) { activated = false; displayMessage("Internal frame deactivated", e); } }); } |
|
disconnectMe(); | public void internalFrameClosed(InternalFrameEvent e) {// displayMessage("Internal frame closed", e); } |
|
displayMessage("Internal frame deactivated", e); | public void internalFrameDeactivated(InternalFrameEvent e) { activated = false; displayMessage("Internal frame deactivated", e); } |
|
System.out.println("update"); | public void update(Graphics g) { paint(g); System.out.println("update"); } |
|
try { frame.setMaximum(true); } catch (java.beans.PropertyVetoException pve) { System.out.println("Can not set maximum " + pve.getMessage()); } | public void addSessionView(String tabText,Session session) { MyInternalFrame frame = new MyInternalFrame(); frame.setVisible(true); desktop.add(frame); selectedIndex = desktop.getComponentCount(); frame.setContentPane(session); try { frame.setSelected(true); } catch (java.beans.PropertyVetoException e) {} session.addSessionListener(this); session.addSessionJumpListener(this); } |
|
this.repaint(); | public void removeSessionView(Session targetSession) { int index = getIndexOfSession(targetSession); System.out.println("session found and closing down " + index); targetSession.removeSessionListener(this); targetSession.removeSessionJumpListener(this); desktop.remove(index); } |
|
attribOrder.add("errorValue"); | private void init() { // append more attributes attribOrder.add("upperErrorValue"); attribOrder.add("lowerErrorValue"); attribOrder.add("errorValue"); //set up the attribute hashtable key with the default initial value attribHash.put("upperErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("lowerErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("errorValue", new XMLAttribute(null, Constants.STRING_TYPE)); } |
|
attribHash.put("errorValue", new XMLAttribute(null, Constants.STRING_TYPE)); | private void init() { // append more attributes attribOrder.add("upperErrorValue"); attribOrder.add("lowerErrorValue"); attribOrder.add("errorValue"); //set up the attribute hashtable key with the default initial value attribHash.put("upperErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("lowerErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("errorValue", new XMLAttribute(null, Constants.STRING_TYPE)); } |
|
i++; | while (++i < abyte0.length && abyte0[i + 1] != IAC); | protected final boolean negotiate(byte abyte0[]) throws IOException { int i = 0; // from server negotiations if(abyte0[i] == IAC) { // -1 while(i < abyte0.length && abyte0[i++] == -1) switch(abyte0[i++]) { // we will not worry about what it WONT do case WONT: // -4 default: break; case DO: //-3 switch(abyte0[i]) { case TERMINAL_TYPE: // 24 baosp.write(IAC); baosp.write(WILL); baosp.write(TERMINAL_TYPE); writeByte(baosp.toByteArray()); baosp.reset(); break; case OPT_END_OF_RECORD: // 25 baosp.write(IAC); baosp.write(WILL); baosp.write(OPT_END_OF_RECORD); writeByte(baosp.toByteArray()); baosp.reset(); break; case TRANSMIT_BINARY: // 0 baosp.write(IAC); baosp.write(WILL); baosp.write(TRANSMIT_BINARY); writeByte(baosp.toByteArray()); baosp.reset(); break; case TIMING_MARK: // 6 rfc860// System.out.println("Timing Mark Received and notifying " +// "the server that we will not do it"); baosp.write(IAC); baosp.write(WONT); baosp.write(TIMING_MARK); writeByte(baosp.toByteArray()); baosp.reset(); break; case NEW_ENVIRONMENT: // 39 rfc1572 if (devName == null) { baosp.write(IAC); baosp.write(WONT); baosp.write(NEW_ENVIRONMENT); writeByte(baosp.toByteArray()); baosp.reset(); } else { System.out.println(devName); baosp.write(IAC); baosp.write(WILL); baosp.write(NEW_ENVIRONMENT); writeByte(baosp.toByteArray()); baosp.reset(); } break; default: // every thing else we will not do at this time baosp.write(IAC); baosp.write(WONT); baosp.write(abyte0[i]); // either writeByte(baosp.toByteArray()); baosp.reset(); break; } i++; break; case WILL: switch(abyte0[i]) { case OPT_END_OF_RECORD: // 25 baosp.write(IAC); baosp.write(DO); baosp.write(OPT_END_OF_RECORD); writeByte(baosp.toByteArray()); baosp.reset(); break; case TRANSMIT_BINARY: // '\0' baosp.write(IAC); baosp.write(DO); baosp.write(TRANSMIT_BINARY); writeByte(baosp.toByteArray()); baosp.reset(); break; } i++; break; case SB: // -6 if(abyte0[i] == NEW_ENVIRONMENT && abyte0[i + 1] == 1) { negNewEnvironment(); i++; } if(abyte0[i] == TERMINAL_TYPE && abyte0[i + 1] == 1) { baosp.write(IAC); baosp.write(SB); baosp.write(TERMINAL_TYPE); baosp.write(QUAL_IS); if(!support132) baosp.write((new String("IBM-3179-2")).getBytes()); else baosp.write((new String("IBM-3477-FC")).getBytes()); baosp.write(IAC); baosp.write(SE); writeByte(baosp.toByteArray()); baosp.reset(); i++; } i++; break; } return true; } else { return false; } } |
exd.printStackTrace(); | public void run () { while (keepTrucking) { try { bk = (Stream5250)dsq.get(); } catch (InterruptedException ie) { System.out.println(" vt thread interrupted and stopping "); keepTrucking = false; continue; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); invited = false; screen52.setCursorOff();// System.out.println("operation code: " + bk.getOpCode()); if (bk == null) continue; switch (bk.getOpCode()) { case 00:// System.out.println("No operation"); break; case 1:// System.out.println("Invite Operation"); parseIncoming();// screen52.setKeyboardLocked(false); pendingUnlock = true; cursorOn = true; setInvited(); break; case 2:// System.out.println("Output Only"); parseIncoming();// System.out.println(screen52.dirty); screen52.updateDirty(); // invited = true; break; case 3:// System.out.println("Put/Get Operation"); parseIncoming();// inviteIt =true; setInvited(); break; case 4:// System.out.println("Save Screen Operation"); parseIncoming(); break; case 5:// System.out.println("Restore Screen Operation"); parseIncoming(); break; case 6:// System.out.println("Read Immediate"); sendAidKey(0); break; case 7:// System.out.println("Reserved"); break; case 8:// System.out.println("Read Screen Operation"); try { readScreen(); } catch (IOException ex) { } break; case 9:// System.out.println("Reserved"); break; case 10:// System.out.println("Cancel Invite Operation"); cancelInvite(); break; case 11:// System.out.println("Turn on message light"); screen52.setMessageLightOn(); screen52.setCursorOn(); break; case 12:// System.out.println("Turn off Message light"); screen52.setMessageLightOff(); screen52.setCursorOn(); break; default: break; } if (screen52.isUsingGuiInterface()) screen52.drawFields();// if (screen52.screen[0][1].getChar() == '#' &&// screen52.screen[0][2].getChar() == '!')// execCmd();// else { if (screen52.isHotSpots()) { screen52.checkHotSpots(); } try { screen52.updateDirty(); } catch (Exception exd ) { System.out.println(" tnvt.run: " + exd.getMessage()); } if (pendingUnlock) screen52.setKeyboardLocked(false); if (cursorOn && !screen52.isKeyboardLocked()) { screen52.setCursorOn(); cursorOn = false; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); } } |
|
public void setInput(Object input) | public void setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata) | public void setInput(Object input) { setInput(input, false, false); } |
setInput(input, false, false); | Class[] okClasses = originatingProvider.getInputTypes(); if (okClasses == null) { if (!(input instanceof ImageInputStream)) throw new IllegalArgumentException(); } else { boolean classOk = false; for (int i = 0; i < okClasses.length; ++i) if (okClasses[i].isInstance(input)) classOk = true; if (!classOk) throw new IllegalArgumentException(); } this.input = input; this.seekForwardOnly = seekForwardOnly; this.ignoreMetadata = ignoreMetadata; this.minIndex = 0; | public void setInput(Object input) { setInput(input, false, false); } |
throw new Error("setHelpMenu() not yet implemented."); | public void setHelpMenu(JMenu menu) { } |
|
ValueListInterface valueListObj = (ValueListInterface) iter.next(); | ValueList valueListObj = (ValueList) iter.next(); | protected String basicXMLWriter ( Writer outputWriter, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) throws java.io.IOException { //while writing out, attribHash should not be changed synchronized (attribHash) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write( indent); // indent node if desired outputWriter.write("<" + nodeNameString); // print opening statement } // gather info about Attributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { int size = attribs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) attribs.get(i); outputWriter.write( " " + item.get("name") + "=\""); // this slows things down, should we use? writeOutAttribute(outputWriter, (String) item.get("value")); // outputWriter.write((String) item.get("value")); outputWriter.write( "\"" ); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { outputWriter.write( ">"); if ((Specification.getInstance().isPrettyXDFOutput()) && (pcdata == null)) outputWriter.write( Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { if (hasValueListCompactDescription && valueListXMLItemName.equals(item.get("name"))) { Iterator iter = valueListObjects.iterator(); while(iter.hasNext()) { ValueListInterface valueListObj = (ValueListInterface) iter.next(); // Grouping *may* differ between the values held in each ValueLists. To check we // if all valueListObjects are 'kosher' we use the first value in the values // list of each ValueListObj as a reference object and compare it to all other // values in that list (but not the lists of values in other ValueListObj). Yes, // this can be slow for large lists of values but is the correct thing to do. List values = valueListObj.getValues(); Value valueObj = (Value) values.get(0); // *sigh* Yes, we have to check that all values belong to // the same groups, or problems will arise in the output. Do that here. boolean canUseCompactValueDescription = true; Set firstValueGroups = valueObj.openGroupNodeHash; Iterator valueIter = values.iterator(); valueIter.next(); // no need to do first group while (valueIter.hasNext()) { Value thisValue = (Value) valueIter.next(); if (thisValue != null) { Set thisValuesGroups = thisValue.openGroupNodeHash; if (!firstValueGroups.equals(thisValuesGroups)) { // Note this comparison also does size too Log.infoln("Cant use short description for values because some values have differing groups! Using long description instead."); canUseCompactValueDescription = false; break; } } } if (canUseCompactValueDescription) { // use compact description indent = dealWithClosingGroupNodes((BaseObject) valueObj, outputWriter, indent); indent = dealWithOpeningGroupNodes((BaseObject) valueObj, outputWriter, indent); String newindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); // now print the valuelist itself valueListObj.toXMLWriter(outputWriter, newindent); } else { // use regular (long) method List objectList = (List) item.get("value"); indent = objectListToXMLWriter(outputWriter, objectList, indent); } } } else { // use regular method List objectList = (List) item.get("value"); indent = objectListToXMLWriter(outputWriter, objectList, indent); } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { indent = dealWithClosingGroupNodes(containedObj, outputWriter, indent); indent = dealWithOpeningGroupNodes(containedObj, outputWriter, indent); String newindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); containedObj.toXMLWriter(outputWriter, newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { outputWriter.write(entifyString(pcdata)); }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write(indent + Specification.getInstance().getPrettyXDFOutputIndentation()); outputWriter.write( "<" + noChildObjectNodeName + "/>"); if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write( Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputWriter, indent); if (Specification.getInstance().isPrettyXDFOutput() && pcdata == null) outputWriter.write( indent); if (!dontCloseNode) outputWriter.write( "</"+nodeNameString+">"); } } else { if (nodeNameString != null) { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) outputWriter.write( ">"); } else { // no sub-objects, just close this node outputWriter.write( "/>"); } } } return nodeNameString; } //synchronize } |
protected void setValueListObj (ValueListInterface valueListObj) | protected void setValueListObj (ValueList valueListObj) | protected void setValueListObj (ValueListInterface valueListObj) { resetBaseValueListObjects(); addValueListObj(valueListObj); } |
if (bindings == null) { bindings = new JTextComponent.KeyBinding[0]; defaults.put(prefix + ".keyBindings", bindings); } | protected Keymap createKeymap() { String prefix = getPropertyPrefix(); UIDefaults defaults = UIManager.getLookAndFeelDefaults(); JTextComponent.KeyBinding[] bindings = (JTextComponent.KeyBinding[]) defaults.get(prefix + ".keyBindings"); Keymap km = JTextComponent.addKeymap(getKeymapName(), JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP)); JTextComponent.loadKeymap(km, bindings, textComponent.getActions()); return km; } |
|
boolean editable = ((Boolean) event.getNewValue()).booleanValue(); | protected void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("editable")) { boolean editable = ((Boolean) event.getNewValue()).booleanValue(); // Changing the color only if the current background is an instance of // ColorUIResource is the behavior of the RI. if (textComponent.getBackground() instanceof ColorUIResource) textComponent.setBackground(editable ? background : inactiveBackground); } } |
|
textComponent.setBackground(editable ? background : inactiveBackground); | { Color c = null; Color old = textComponent.getBackground(); String prefix = getPropertyPrefix(); if (! textComponent.isEnabled()) c = SharedUIDefaults.getColor(prefix + ".disabledBackground"); if (c == null && ! textComponent.isEditable()) c = SharedUIDefaults.getColor(prefix + ".inactiveBackground"); if (c == null) c = SharedUIDefaults.getColor(prefix + ".background"); if (c != null && c != old) { textComponent.setBackground(c); } } | protected void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("editable")) { boolean editable = ((Boolean) event.getNewValue()).booleanValue(); // Changing the color only if the current background is an instance of // ColorUIResource is the behavior of the RI. if (textComponent.getBackground() instanceof ColorUIResource) textComponent.setBackground(editable ? background : inactiveBackground); } } |
int newsize = shortIndex; | int newsize = shortIndex+1; | private void checkDataArrayBounds (int longIndex, int shortIndex, int type) throws SetDataException { // Does the location exist yet? If not, create the primative arrays // that lie along the short axis int shortAxisSize = getShortAxis().getLength(); // is the long array too small? if (longDataArray.size() < (longIndex+1)) { int maxDeclLongArraySize = getMaxLongArraySize(); // should be held in private var int expandSize = longIndex > maxDeclLongArraySize ? longIndex : maxDeclLongArraySize; expandSize *= expandFactor; // add in additional amount to prevent us from doing this too much expandLongArray(expandSize); } // is the short array too small? has it been init'd even yet? // we perform checks here.. if (longDataArray.get(longIndex) == null) { // init/create the short array longDataArray.set( longIndex, new byte[shortAxisSize]); if (type == DOUBLE_DATA_TYPE) { longDataArray.set(longIndex+1, new double [shortAxisSize]); } else if (type == INT_DATA_TYPE) { longDataArray.set(longIndex+1, new int [shortAxisSize]); } else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, new short [shortAxisSize]); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, new long [shortAxisSize]); } else if (type == STRING_DATA_TYPE) { longDataArray.set(longIndex+1, new String [shortAxisSize]); } } else { int currentShortAxisSize = getLongDataArraySize(longIndex, type); // requested short axis location not exist? if (currentShortAxisSize < shortIndex) { // should flag the user that need to add AxisValue first if (shortIndex > shortAxisSize) { Log.errorln ("Error: axis lacks an AxisValue at location requested in setData()."); throw new SetDataException(); } else { // add in short axis location to local short array(s) int newsize = shortIndex; newsize *= expandFactor; // expand short axis by expandFactor longDataArray.set(longIndex, expandArray((byte []) longDataArray.get(longIndex), newsize)); if (type == DOUBLE_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((double[]) longDataArray.get(longIndex+1), newsize)); } else if (type == INT_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((int[]) longDataArray.get(longIndex+1), newsize)); } else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((short[]) longDataArray.get(longIndex+1), newsize)); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((long []) longDataArray.get(longIndex+1), newsize)); } else if (type == STRING_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((String []) longDataArray.get(longIndex+1), newsize)); } } } } } |
Log.debugln("Expanding Long array size to "+newsize+" from "+currentSize +" (add capacity is "+additionalCapacity+")"); | Log.debugln(" DataCube is expanding internal LongDataArray size to "+(newsize*2)+" from "+(currentSize*2)+" (added capacity is:"+additionalCapacity+")"); | private void expandLongArray (int newsize) { int currentSize = longDataArray.size(); int additionalCapacity = (newsize - currentSize) * 2; // mult by 2 to allow for shadow byte array if (additionalCapacity > 0) {Log.debugln("Expanding Long array size to "+newsize+" from "+currentSize +" (add capacity is "+additionalCapacity+")"); List moreArray = Collections.synchronizedList(new ArrayList(additionalCapacity)); for (int i = 0; i < additionalCapacity; i++) { moreArray.add(null); // populate with nulls } longDataArray.addAll(moreArray); } } |
List axisList = parentArray.getAxes(); | public Object getData (Locator locator) throws NoDataException { List axisList = parentArray.getAxes(); int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.get(longDataArray.get(longIndex+1), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } |
|
List axisList = parentArray.getAxes(); | public double getDoubleData (Locator locator) throws NoDataException { List axisList = parentArray.getAxes(); int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getDouble(longDataArray.get(longIndex+1), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } |
|
List axisList = parentArray.getAxes(); | public int getIntData (Locator locator) throws NoDataException { List axisList = parentArray.getAxes(); int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getInt(longDataArray.get(longIndex), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } |
|
List axisList = parentArray.getAxes(); | public long getLongData (Locator locator) throws NoDataException { List axisList = parentArray.getAxes(); int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getLong(longDataArray.get(longIndex), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } |
|
shortAxis = (AxisInterface) parentArray.getAxes().get(1); | shortAxis = (AxisInterface) axisList.get(1); | private AxisInterface getShortAxis () { AxisInterface shortAxis = null; List axisList = parentArray.getAxes(); if (axisList.size() > 1) { shortAxis = (AxisInterface) parentArray.getAxes().get(1); } return shortAxis; } |
List axisList = parentArray.getAxes(); | public short getShortData (Locator locator) throws NoDataException { List axisList = parentArray.getAxes(); int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getShort(longDataArray.get(longIndex), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } } |
|
Log.errorln("in DataCube, reset(), method is empty needs to be implemented!"); | Log.debugln("in DataCube, called reset()"); | public void reset() { Log.errorln("in DataCube, reset(), method is empty needs to be implemented!"); // reset the longDataArray, will free all related shortDataArrays. // What else needs to be done? // this.longDataArray = Collections.synchronizedList(new ArrayList()); } |
longDataArray = Collections.synchronizedList(new ArrayList()); | public void reset() { Log.errorln("in DataCube, reset(), method is empty needs to be implemented!"); // reset the longDataArray, will free all related shortDataArrays. // What else needs to be done? // this.longDataArray = Collections.synchronizedList(new ArrayList()); } |
|
firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, oldPainted, | firePropertyChange("borderPainted", oldPainted, | public void setBorderPainted(boolean painted) { if (painted != paintBorder) { boolean oldPainted = paintBorder; paintBorder = painted; firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, oldPainted, paintBorder); } } |
firePropertyChange(INDETERMINATE_CHANGED_PROPERTY, olddeter, | firePropertyChange("indeterminate", olddeter, | public void setIndeterminate(boolean newValue) { if (indeterminate != newValue) { boolean olddeter = indeterminate; indeterminate = newValue; firePropertyChange(INDETERMINATE_CHANGED_PROPERTY, olddeter, indeterminate); } } |
firePropertyChange(ORIENTATION_CHANGED_PROPERTY, oldOrientation, | firePropertyChange("orientation", oldOrientation, | public void setOrientation(int orientation) { if (orientation != VERTICAL && orientation != HORIZONTAL) throw new IllegalArgumentException("orientation must be one of VERTICAL or HORIZONTAL"); if (this.orientation != orientation) { int oldOrientation = this.orientation; this.orientation = orientation; firePropertyChange(ORIENTATION_CHANGED_PROPERTY, oldOrientation, this.orientation); } } |
firePropertyChange(STRING_CHANGED_PROPERTY, oldString, progressString); | firePropertyChange("string", oldString, progressString); | public void setString(String string) { if (((string == null || progressString == null) && string != progressString) || (string != null && ! string.equals(progressString))) { String oldString = progressString; progressString = string; firePropertyChange(STRING_CHANGED_PROPERTY, oldString, progressString); } } |
firePropertyChange(STRING_PAINTED_CHANGED_PROPERTY, oldPainted, | firePropertyChange("stringPainted", oldPainted, | public void setStringPainted(boolean painted) { if (paintString != painted) { boolean oldPainted = paintString; paintString = painted; firePropertyChange(STRING_PAINTED_CHANGED_PROPERTY, oldPainted, paintString); } } |
if (accessibleContext == null) accessibleContext = new AccessibleJFrame(); | public AccessibleContext getAccessibleContext() { return accessibleContext; } |
|
bad.minor = Minor.Any; | public static NameDynAnyPair extract(Any any) { try { return ((NameDynAnyPairHolder) any.extract_Streamable()).value; } catch (ClassCastException cex) { BAD_OPERATION bad = new BAD_OPERATION("NameDynAnyPair expected"); bad.initCause(cex); throw bad; } } |
|
return calculateInsetArea(b, c.getInsets(), r); | if (r == null) r = new Rectangle(); Insets i = c.getInsets(); r.x = b.x + i.left; r.width = b.width - i.left - i.right; r.y = b.y + i.top; r.height = b.height - i.top - i.bottom; return r; | public static Rectangle calculateInnerArea(JComponent c, Rectangle r) { Rectangle b = getLocalBounds(c); return calculateInsetArea(b, c.getInsets(), r); } |
if (instances == null) instances = new HashMap(); Object o = instances.get(component); MetalComboBoxUI instance; if (o == null) { instance = new MetalComboBoxUI(); instances.put(component, instance); } else instance = (MetalComboBoxUI) o; return instance; | return new MetalComboBoxUI(); | public static ComponentUI createUI(JComponent component) { if (instances == null) instances = new HashMap(); Object o = instances.get(component); MetalComboBoxUI instance; if (o == null) { instance = new MetalComboBoxUI(); instances.put(component, instance); } else instance = (MetalComboBoxUI) o; return instance; } |
Log.error("XDF::BinaryInteger cant handle > 32 bit Integer Numbers"); | Log.error("BinaryInteger cant handle > 32 bit Integer Numbers"); | public String templateNotation(String strEndian, String strEncoding) { if (numOfBytes() >4) { Log.error("XDF::BinaryInteger cant handle > 32 bit Integer Numbers"); Log.error("returning null"); return null; } if (!Utility.isValidEndian(strEndian)) { Log.error("not a valid endian, returning null"); return null; } // we hardwired 'BigEndian" response here. Bad! if (strEndian.equals(Constants.BIG_ENDIAN)) return "N"; else return "V"; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.