joafip-svn Mailing List for java data object persistence in file (Page 22)
Brought to you by:
luc_peuvrier
You can subscribe to this list here.
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
(102) |
Nov
(52) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2012 |
Jan
(4) |
Feb
|
Mar
(14) |
Apr
(116) |
May
(100) |
Jun
(14) |
Jul
|
Aug
|
Sep
(30) |
Oct
|
Nov
(108) |
Dec
(2) |
|
From: <luc...@us...> - 2011-10-12 03:04:30
|
Revision: 2917
http://joafip.svn.sourceforge.net/joafip/?rev=2917&view=rev
Author: luc_peuvrier
Date: 2011-10-12 03:04:21 +0000 (Wed, 12 Oct 2011)
Log Message:
-----------
direct field access checker WIP
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumStackEltType.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumType.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNode.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/CheckMethodVisitor.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/ClassConstraintChecker.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/OpcodeInterpreter.java
trunk/joafip/src/test/java/net/sf/joafip/entity/BobForExport.java
trunk/joafip/src/test/java/net/sf/joafip/entity/ClassForExport.java
trunk/joafip/src/test/java/net/sf/joafip/export_import/Container.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionTreeMapNosubsNoG.java
trunk/joafip/src/test/resources/log4j.properties
trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/StoreServiceByteCodeTests.java
Added Paths:
-----------
trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/
trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/AbstractToCheckClass.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/ForTestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/TestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/ToCheckClass.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/proxy/
trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/proxy/StoreServiceByteCodeProxyTests.java
Removed Paths:
-------------
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractToCheckClass.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ForTestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ToCheckClass.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumStackEltType.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumStackEltType.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumStackEltType.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -28,8 +28,6 @@
*
*/
public enum EnumStackEltType {
- /** no type */
- VOID(0),
/** reference on object or array */
REF(1),
/**/
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumType.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumType.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumType.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -29,7 +29,7 @@
*/
public enum EnumType {
/** no type */
- VOID(0, EnumStackEltType.VOID, null),
+ VOID(0, null, null),
/** reference on object or array */
REF(1, EnumStackEltType.REF, null),
/**/
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNode.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNode.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNode.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -94,7 +94,9 @@
public void setBeforeExecutionStackElement(
final StackElement beforeExecutionStackElement) {
- assert this.beforeExecutionStackElement == null;
+ assert this.beforeExecutionStackElement == null : "to set to\n"
+ + beforeExecutionStackElement + "\n and is\n"
+ + this.beforeExecutionStackElement;
this.beforeExecutionStackElement = beforeExecutionStackElement;
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/CheckMethodVisitor.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/CheckMethodVisitor.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/CheckMethodVisitor.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -35,8 +35,8 @@
import net.sf.joafip.asm.Label;
import net.sf.joafip.asm.MethodVisitor;
import net.sf.joafip.asm.Opcodes;
+import net.sf.joafip.logger.JoafipLogger;
import net.sf.joafip.store.entity.proxy.DirectAccessInfo;
-import net.sf.joafip.store.entity.proxy.EnumStackEltType;
import net.sf.joafip.store.entity.proxy.OpcodeNode;
import net.sf.joafip.store.entity.proxy.OpcodeNodeAloadThis;
import net.sf.joafip.store.entity.proxy.OpcodeNodeDup;
@@ -64,6 +64,9 @@
@NotStorableClass
public class CheckMethodVisitor implements MethodVisitor, Opcodes {
+ private final static JoafipLogger LOGGER = JoafipLogger
+ .getLogger(CheckMethodVisitor.class);
+
private final ICheckMethodListener listener;
private transient OpcodeNode startOpcodeNode;
@@ -138,6 +141,9 @@
final String unassembled = listener.unassembled(methodAbsoluteName);
throw new RuntimeEnhanceException(new EnhanceException(
"checking:\n" + unassembled, exception));
+ } catch (Error error) {
+ LOGGER.error(listener.unassembled(methodAbsoluteName));
+ throw error;
} finally {
currentOpcodeNode = null;// NOPMD
opcodeByLabelMap = null;// NOPMD
@@ -153,8 +159,7 @@
final Deque<StackElement> stackElementQue = new LinkedList<StackElement>();
final Set<OpcodeNode> visited = new HashSet<OpcodeNode>();
OpcodeNode currentOpcodeNode = startOpcodeNode;
- StackElement stackElement = new StackElement(null,
- EnumStackEltType.VOID);
+ StackElement stackElement = null;
while (currentOpcodeNode != null) {
listener.currentOpcode(currentOpcodeNode);
currentOpcodeNode.setBeforeExecutionStackElement(stackElement);
@@ -169,9 +174,10 @@
stackElementQue.add(stackElement);
}
// FIXMELUC __________________________stack change
- // else if (stackElement != next
- // .getBeforeExecutionStackElement()) {
- // throw new EnhanceException("stack change");
+ // else if (stackElement !=
+ // next.getBeforeExecutionStackElement()) {
+ // throw new EnhanceException("stack change:\n" + stackElement
+ // + "\n" + next.getBeforeExecutionStackElement());
// }
}
currentOpcodeNode = toVisitQue.poll();
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/ClassConstraintChecker.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/ClassConstraintChecker.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/ClassConstraintChecker.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -100,23 +100,23 @@
if (checkMethodListener.hasDirectAccess()) {
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("direct field access:\n");
- String previousMethodAbsoluteName = null;
+ // String previousMethodAbsoluteName = null;
for (DirectAccessInfo directAccessInfo : checkMethodListener
.getDirectAccessSet()) {
stringBuilder.append(directAccessInfo.toString());
stringBuilder.append('\n');
- if (previousMethodAbsoluteName != null
- && !previousMethodAbsoluteName.equals(directAccessInfo
- .getMethodAbsoluteName())) {
- stringBuilder.append(checkMethodListener
- .unassembled(directAccessInfo
- .getMethodAbsoluteName()));
- }
- previousMethodAbsoluteName = directAccessInfo
- .getMethodAbsoluteName();
+ // if (previousMethodAbsoluteName != null
+ // && !previousMethodAbsoluteName.equals(directAccessInfo
+ // .getMethodAbsoluteName())) {
+ // stringBuilder.append(checkMethodListener
+ // .unassembled(directAccessInfo
+ // .getMethodAbsoluteName()));
+ // }
+ // previousMethodAbsoluteName = directAccessInfo
+ // .getMethodAbsoluteName();
}
- stringBuilder.append(checkMethodListener
- .unassembled(previousMethodAbsoluteName));
+ // stringBuilder.append(checkMethodListener
+ // .unassembled(previousMethodAbsoluteName));
stringBuilder.append('\n');
throw new EnhanceException(stringBuilder.toString());
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/OpcodeInterpreter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/OpcodeInterpreter.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/OpcodeInterpreter.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -38,6 +38,8 @@
@NotStorableClass
public final class OpcodeInterpreter {
+ private static final String EMPTY_STACK = "empty stack";
+
private static class OpcodeDesc {
private static final EnumType[] EMPTY_POP_TYPES = new EnumType[] {};
@@ -632,16 +634,19 @@
public StackElement pop(final StackElement pointer, final EnumType type)
throws EnhanceException {
+ if (pointer == null) {
+ throw new EnhanceException(EMPTY_STACK);
+ }
EnumStackEltType stackEltType = pointer.getType();
if (!stackEltType.equals(type.getLowType())) {
throw new EnhanceException("type mismatch " + stackEltType
+ " in the stack for " + type.getLowType() + " expected");
}
StackElement newPointer = pointer.getPrevious();
- if (newPointer == null) {
- throw new EnhanceException("empty stack");
- }
if (type.getCategory() == 2) {
+ if (newPointer == null) {
+ throw new EnhanceException(EMPTY_STACK);
+ }
stackEltType = newPointer.getType();
if (!stackEltType.equals(type.getHighType())) {
throw new EnhanceException("type mismatch " + stackEltType
@@ -649,9 +654,6 @@
+ " expected");
}
newPointer = newPointer.getPrevious();
- if (newPointer == null) {
- throw new EnhanceException("empty stack");
- }
}
return newPointer;
}
@@ -735,11 +737,10 @@
private StackElement pop(final StackElement currentStackElement)
throws EnhanceException {
- final StackElement previous = currentStackElement.getPrevious();
- if (previous == null) {
- throw new EnhanceException("empty stack");
+ if (currentStackElement == null) {
+ throw new EnhanceException(EMPTY_STACK);
}
- return previous;
+ return currentStackElement.getPrevious();
}
public StackElement interpretePop2(final StackElement currentStackElement)
Modified: trunk/joafip/src/test/java/net/sf/joafip/entity/BobForExport.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/BobForExport.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/BobForExport.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -572,7 +572,9 @@
} else if (!objectList.equals(other.getObjectList())) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("objectList not equals\nthis:\n"
+ + objectList.getClass().getName() + "\n"
+ objectList.toString() + "\nother:\n"
+ + other.getObjectList().getClass().getName() + "\n"
+ other.getObjectList());
}
return false;
Modified: trunk/joafip/src/test/java/net/sf/joafip/entity/ClassForExport.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/ClassForExport.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/ClassForExport.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -97,12 +97,12 @@
if (field == null) {
if (other.getField() != null)
return false;
- } else if (!field.equals(other.getField()))
+ } else if (!field.equals(other.getField2()))
return false;
if (transientField == null) {
if (other.getTransientField() != null)
return false;
- } else if (!transientField.equals(other.getTransientField()))
+ } else if (!transientField.equals(other.getTransientField2()))
return false;
return true;
}
Modified: trunk/joafip/src/test/java/net/sf/joafip/export_import/Container.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/export_import/Container.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/test/java/net/sf/joafip/export_import/Container.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -703,7 +703,7 @@
LOGGER.error("bad subTreeMap size");
stateOk = false;
}
- if (LOGGER.debugEnabled) {
+ if (LOGGER.isDebugEnabled()) {
final StringBuilder stringBuilder = new StringBuilder();
for (Map.Entry<String, String> entry : subTreeMap.entrySet()) {
stringBuilder.append(entry.getKey());
@@ -723,7 +723,7 @@
LOGGER.error("subTreeMapSetIterator must have next");
stateOk = false;
}
- if (LOGGER.debugEnabled) {
+ if (LOGGER.isDebugEnabled()) {
LOGGER.debug("subTreeMapValueIterator is "
+ subTreeMapValueIterator.getClass());
final Iterator<Entry<String, String>> iterator =
Copied: trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/AbstractToCheckClass.java (from rev 2916, trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractToCheckClass.java)
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/AbstractToCheckClass.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/AbstractToCheckClass.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.service.bytecode.proxy;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class AbstractToCheckClass {
+
+ private Object object;
+
+ private boolean booleanValue;
+
+ private byte byteValue;
+
+ private char charValue;
+
+ private short shortValue;
+
+ private int intValue;
+
+ private long longValue;
+
+ private float floatValue;
+
+ private double doubleValue;
+
+ public AbstractToCheckClass() {
+ super();
+ }
+
+ public AbstractToCheckClass(final Object object, final boolean booleanValue) {
+ super();
+ this.object = object;
+ this.booleanValue = booleanValue;
+ }
+
+ public AbstractToCheckClass(final Object object, final byte byteValue) {
+ super();
+ this.object = object;
+ this.byteValue = byteValue;
+ }
+
+ public AbstractToCheckClass(final Object object, final char charValue) {
+ super();
+ this.object = object;
+ this.charValue = charValue;
+ }
+
+ public AbstractToCheckClass(final Object object, final short shortValue) {
+ super();
+ this.object = object;
+ this.shortValue = shortValue;
+ }
+
+ public AbstractToCheckClass(final Object object, final int intValue) {
+ super();
+ this.object = object;
+ this.intValue = intValue;
+ }
+
+ public AbstractToCheckClass(final Object object, final long longValue) {
+ super();
+ this.object = object;
+ this.longValue = longValue;
+ }
+
+ public AbstractToCheckClass(final Object object, final float floatValue) {
+ super();
+ this.object = object;
+ this.floatValue = floatValue;
+ }
+
+ public AbstractToCheckClass(final Object object, final double doubleValue) {
+ super();
+ this.object = object;
+ this.doubleValue = doubleValue;
+ }
+
+ public Object getObject() {
+ return object;
+ }
+
+ public boolean isBooleanValue() {
+ return booleanValue;
+ }
+
+ public byte getByteValue() {
+ return byteValue;
+ }
+
+ public char getCharValue() {
+ return charValue;
+ }
+
+ public short getShortValue() {
+ return shortValue;
+ }
+
+ public int getIntValue() {
+ return intValue;
+ }
+
+ public long getLongValue() {
+ return longValue;
+ }
+
+ public float getFloatValue() {
+ return floatValue;
+ }
+
+ public double getDoubleValue() {
+ return doubleValue;
+ }
+}
Copied: trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/ForTestCheckMethodVisitor.java (from rev 2916, trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ForTestCheckMethodVisitor.java)
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/ForTestCheckMethodVisitor.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/ForTestCheckMethodVisitor.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.service.bytecode.proxy;
+
+import net.sf.joafip.store.service.bytecode.proxy.CheckMethodVisitor;
+import net.sf.joafip.store.service.bytecode.proxy.ICheckMethodListener;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class ForTestCheckMethodVisitor extends CheckMethodVisitor {
+
+ public ForTestCheckMethodVisitor(final ICheckMethodListener listener,
+ final String aboluteMethodName) {
+ super(listener, aboluteMethodName);
+ }
+}
Copied: trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/TestCheckMethodVisitor.java (from rev 2916, trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestCheckMethodVisitor.java)
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/TestCheckMethodVisitor.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/TestCheckMethodVisitor.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -0,0 +1,308 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.service.bytecode.proxy;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+import net.sf.joafip.AbstractJoafipTestCase;
+import net.sf.joafip.TestException;
+import net.sf.joafip.asm.AnnotationVisitor;
+import net.sf.joafip.asm.Attribute;
+import net.sf.joafip.asm.ClassReader;
+import net.sf.joafip.asm.ClassVisitor;
+import net.sf.joafip.asm.FieldVisitor;
+import net.sf.joafip.asm.MethodVisitor;
+import net.sf.joafip.asm.Type;
+import net.sf.joafip.store.entity.proxy.DirectAccessInfo;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+import net.sf.joafip.store.service.proxy.CheckMethodListener;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class TestCheckMethodVisitor extends AbstractJoafipTestCase implements
+ ClassVisitor {
+
+ private transient String className;
+
+ private transient CheckMethodListener checkMethodListener;
+
+ private transient String methodName;
+
+ private transient String methodDescriptor;
+
+ public TestCheckMethodVisitor() throws TestException {
+ super();
+ }
+
+ public TestCheckMethodVisitor(final String name) throws TestException {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception { // NOPMD
+ checkMethodListener = new CheckMethodListener();
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception { // NOPMD
+ className = null;// NOPMD
+ checkMethodListener = null;// NOPMD
+ methodName = null;// NOPMD
+ methodDescriptor = null;// NOPMD
+ super.tearDown();
+ }
+
+ public void testDefaultConstructor() throws NoSuchMethodException,
+ IOException, EnhanceException {
+ check(null, new Class[] {});
+ assertFalse("default constructor must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testBooleanConstructor() throws NoSuchMethodException,
+ IOException, EnhanceException {
+ check(null, new Class[] { boolean.class });
+ assertFalse("constructor(boolean) must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testByteConstructor() throws NoSuchMethodException,
+ IOException, EnhanceException {
+ check(null, new Class[] { byte.class });
+ assertFalse("constructor(byte) must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testCharConstructor() throws NoSuchMethodException,
+ IOException, EnhanceException {
+ check(null, new Class[] { char.class });
+ assertFalse("constructor(char) must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testShortConstructor() throws NoSuchMethodException,
+ IOException, EnhanceException {
+ check(null, new Class[] { short.class });
+ assertFalse("constructor(short) must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testIntConstructor() throws NoSuchMethodException, IOException,
+ EnhanceException {
+ check(null, new Class[] { int.class });
+ assertFalse("constructor(int) must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testLongConstructor() throws NoSuchMethodException,
+ IOException, EnhanceException {
+ check(null, new Class[] { long.class });
+ assertFalse("constructor(long) must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testFloatConstructor() throws NoSuchMethodException,
+ IOException, EnhanceException {
+ check(null, new Class[] { float.class });
+ assertFalse("constructor(float) must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testDoubleConstructor() throws NoSuchMethodException,
+ IOException, EnhanceException {
+ check(null, new Class[] { double.class });
+ assertFalse("constructor(double) must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testGetGlobalCount() throws IOException, EnhanceException,
+ SecurityException, NoSuchMethodException {
+ check("getGlobalCount", new Class[] {});
+ assertFalse("getGlobalCount() must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testSetGlobalCount() throws IOException, EnhanceException,
+ SecurityException, NoSuchMethodException {
+ check("setGlobalCount", new Class[] { int.class });
+ assertFalse("setGlobalCount(int) must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testGetaStaticCount() throws IOException, EnhanceException,
+ SecurityException, NoSuchMethodException {
+ check("getaStaticCount", new Class[] {});
+ assertFalse("getaStaticCount() must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testSetaStaticCount() throws IOException, EnhanceException,
+ SecurityException, NoSuchMethodException {
+ check("setaStaticCount", new Class[] { int.class });
+ assertFalse("setaStaticCount(int) must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testWhileOkMethod() throws IOException, EnhanceException,
+ SecurityException, NoSuchMethodException {
+ check("whileOkMethod", new Class[] {});
+ assertFalse("whileOkMethod() must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ public void testWhileMethod() throws NoSuchMethodException, IOException,
+ EnhanceException {
+ check("whileMethod", new Class[] { Class.class });
+ assertFalse("whileOkMethod() must be ok\n" + directAccess(),
+ checkMethodListener.hasDirectAccess());
+ }
+
+ private String directAccess() {
+ final StringBuilder stringBuilder = new StringBuilder();
+ for (DirectAccessInfo directAccessInfo : checkMethodListener
+ .getDirectAccessSet()) {
+ stringBuilder.append(directAccessInfo.toString());
+ stringBuilder.append('\n');
+ stringBuilder.append(checkMethodListener
+ .unassembled(directAccessInfo.getMethodAbsoluteName()));
+ stringBuilder.append('\n');
+ }
+ return stringBuilder.toString();
+ }
+
+ private void check(final String name, final Class<?>[] parameterTypes)
+ throws NoSuchMethodException, IOException, EnhanceException {
+ if (name == null) {
+ setConstructorTotest(parameterTypes);
+ } else {
+ setMethodTotest(name, parameterTypes);
+ }
+ final InputStream inputStream = ClassLoader
+ .getSystemResourceAsStream("net/sf/joafip/store/service/bytecode/proxy/ToCheckClass.class");
+ final ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
+ int byteValue;
+ while ((byteValue = inputStream.read()) != -1) {// NOPMD
+ byteOutputStream.write(byteValue);
+ }
+ byteOutputStream.close();
+ inputStream.close();
+ final byte[] originalCode = byteOutputStream.toByteArray();
+ final int off = 0;
+ final int len = originalCode.length;
+ final ClassReader classreader = new ClassReader(originalCode, off, len);
+ try {
+ classreader.accept(this, ClassReader.SKIP_FRAMES);
+ } catch (RuntimeEnhanceException exception) {
+ throw (EnhanceException) exception.getCause();
+ }
+ if (logger.debugEnabled) {
+ logger.debug(checkMethodListener.unassembled());
+ }
+ }
+
+ private void setMethodTotest(final String methodName,
+ final Class<?>[] parameterTypes) throws NoSuchMethodException {
+ this.methodName = methodName;
+ final Method method = ToCheckClass.class.getDeclaredMethod(methodName,
+ parameterTypes);
+ methodDescriptor = Type.getMethodDescriptor(method);
+ }
+
+ private void setConstructorTotest(final Class<?>[] parameterTypes)
+ throws NoSuchMethodException {
+ methodName = "<init>";
+ final Constructor<ToCheckClass> constructor = ToCheckClass.class
+ .getConstructor(parameterTypes);
+ methodDescriptor = Type.getConstructorDescriptor(constructor);
+
+ }
+
+ @Override
+ public void visit(final int version, final int access, final String name,
+ final String signature, final String superName,
+ final String[] interfaces) {
+ this.className = name;
+ }
+
+ @Override
+ public MethodVisitor visitMethod(final int access, final String name,
+ final String desc, final String signature, final String[] exceptions) {
+ final ForTestCheckMethodVisitor methodVisitor;
+ if (name.equals(methodName) && desc.equals(methodDescriptor)) {
+ methodVisitor = new ForTestCheckMethodVisitor(checkMethodListener,
+ className + "#" + name + desc);
+ } else {
+ methodVisitor = null;
+ }
+ return methodVisitor;
+ }
+
+ @Override
+ public void visitSource(final String source, final String debug) {
+ // no implementation
+ }
+
+ @Override
+ public void visitOuterClass(final String owner, final String name,
+ final String desc) {
+ // no implementation
+ }
+
+ @Override
+ public AnnotationVisitor visitAnnotation(final String desc,
+ final boolean visible) {
+ // no implementation
+ return null;
+ }
+
+ @Override
+ public void visitAttribute(final Attribute attr) {
+ // no implementation
+ }
+
+ @Override
+ public void visitInnerClass(final String name, final String outerName,
+ final String innerName, final int access) {
+ // no implementation
+ }
+
+ @Override
+ public FieldVisitor visitField(final int access, final String name,
+ final String desc, final String signature, final Object value) {
+ // no implementation
+ return null;
+ }
+
+ @Override
+ public void visitEnd() {
+ // no implementation
+ }
+}
Copied: trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/ToCheckClass.java (from rev 2916, trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ToCheckClass.java)
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/ToCheckClass.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/ToCheckClass.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.service.bytecode.proxy;
+
+/**
+ * to check for persistence class
+ *
+ * @author luc peuvrier
+ *
+ */
+public class ToCheckClass extends AbstractToCheckClass {
+
+ private static int aStaticCount;
+
+ private int globalCount;
+
+ public ToCheckClass() {
+ super();
+ }
+
+ public ToCheckClass(final boolean booleanValue) {
+ super(null, booleanValue);
+ }
+
+ public ToCheckClass(final byte byteValue) {
+ super(null, byteValue);
+ }
+
+ public ToCheckClass(final char charValue) {
+ super(null, charValue);
+ }
+
+ public ToCheckClass(final short shortValue) {
+ super(null, shortValue);
+ }
+
+ public ToCheckClass(final double doubleValue) {
+ super(null, doubleValue);
+ }
+
+ public ToCheckClass(final float floatValue) {
+ super(null, floatValue);
+ }
+
+ public ToCheckClass(final int intValue) {
+ super(null, intValue);
+ }
+
+ public ToCheckClass(final long longValue) {
+ super(null, longValue);
+ }
+
+ public int getGlobalCount() {
+ return globalCount;
+ }
+
+ public void setGlobalCount(final int globalCount) {
+ this.globalCount = globalCount;
+ }
+
+ public int getaStaticCount() {
+ return aStaticCount;
+ }
+
+ public static void setaStaticCount(final int aStaticCount) {
+ ToCheckClass.aStaticCount = aStaticCount;
+ }
+
+ public void incStaticCount() {
+ aStaticCount++;
+ }
+
+ public void whileOkMethod() {
+ int count = 0;
+ while (count < 5) {
+ globalCount++;
+ count++;
+ }
+ }
+
+ public void whileNokMethod(final ToCheckClass toCheckClass) {
+ int count = 0;
+ while (count < 5) {
+ toCheckClass.globalCount++;
+ count++;
+ }
+ }
+
+ private final Class<?> root = Object.class;
+
+ @SuppressWarnings({ "unused", "PMD" })
+ private void whileMethod(Class<?> clazz) {
+ while (clazz != root) {// NOPMD
+ clazz = clazz.getSuperclass();
+ }
+ operation(clazz);
+ }
+
+ @SuppressWarnings("PMD")
+ private void operation(final Class<?> clazz) {
+ }
+}
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionTreeMapNosubsNoG.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionTreeMapNosubsNoG.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionTreeMapNosubsNoG.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -16,6 +16,7 @@
*/
package net.sf.joafip.store.service.collection.nosubs;
+import java.util.AbstractMap;
import java.util.Map;
import java.util.TreeMap;
@@ -44,13 +45,15 @@
}
@Override
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception { // NOPMD
super.setUp();
store = new StoreForTest(1, null, path,
/**/false/* do not manage garbage */);
store.setForceEnhance(TreeMap.class);// NOPMD
store.openAndNewAccessSession(true/* removeFiles */);
store.setSubstitutionOfJavaUtilCollection(false);
+ store.addNotCheckedMethod(TreeMap.class); // NOPMD
+ store.addNotCheckedMethod(AbstractMap.class); // NOPMD
}
@Override
Deleted: trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractToCheckClass.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractToCheckClass.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractToCheckClass.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -1,137 +0,0 @@
-/*
- * Copyright 2011 Luc Peuvrier
- *
- * This file is a part of JOAFIP.
- *
- * JOAFIP is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License.
- *
- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
- * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.gnu.org/licenses/lgpl.html
- *
- * JOAFIP is distributed in the hope that it will be useful, but
- * unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.joafip.store.service.proxy;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-public class AbstractToCheckClass {
-
- private Object object;
-
- private boolean booleanValue;
-
- private byte byteValue;
-
- private char charValue;
-
- private short shortValue;
-
- private int intValue;
-
- private long longValue;
-
- private float floatValue;
-
- private double doubleValue;
-
- public AbstractToCheckClass() {
- super();
- }
-
- public AbstractToCheckClass(final Object object, final boolean booleanValue) {
- super();
- this.object = object;
- this.booleanValue = booleanValue;
- }
-
- public AbstractToCheckClass(final Object object, final byte byteValue) {
- super();
- this.object = object;
- this.byteValue = byteValue;
- }
-
- public AbstractToCheckClass(final Object object, final char charValue) {
- super();
- this.object = object;
- this.charValue = charValue;
- }
-
- public AbstractToCheckClass(final Object object, final short shortValue) {
- super();
- this.object = object;
- this.shortValue = shortValue;
- }
-
- public AbstractToCheckClass(final Object object, final int intValue) {
- super();
- this.object = object;
- this.intValue = intValue;
- }
-
- public AbstractToCheckClass(final Object object, final long longValue) {
- super();
- this.object = object;
- this.longValue = longValue;
- }
-
- public AbstractToCheckClass(final Object object, final float floatValue) {
- super();
- this.object = object;
- this.floatValue = floatValue;
- }
-
- public AbstractToCheckClass(final Object object, final double doubleValue) {
- super();
- this.object = object;
- this.doubleValue = doubleValue;
- }
-
- public Object getObject() {
- return object;
- }
-
- public boolean isBooleanValue() {
- return booleanValue;
- }
-
- public byte getByteValue() {
- return byteValue;
- }
-
- public char getCharValue() {
- return charValue;
- }
-
- public short getShortValue() {
- return shortValue;
- }
-
- public int getIntValue() {
- return intValue;
- }
-
- public long getLongValue() {
- return longValue;
- }
-
- public float getFloatValue() {
- return floatValue;
- }
-
- public double getDoubleValue() {
- return doubleValue;
- }
-}
Deleted: trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ForTestCheckMethodVisitor.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ForTestCheckMethodVisitor.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ForTestCheckMethodVisitor.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -1,39 +0,0 @@
-/*
- * Copyright 2011 Luc Peuvrier
- *
- * This file is a part of JOAFIP.
- *
- * JOAFIP is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License.
- *
- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
- * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.gnu.org/licenses/lgpl.html
- *
- * JOAFIP is distributed in the hope that it will be useful, but
- * unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.joafip.store.service.proxy;
-
-import net.sf.joafip.store.service.bytecode.proxy.CheckMethodVisitor;
-import net.sf.joafip.store.service.bytecode.proxy.ICheckMethodListener;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-public class ForTestCheckMethodVisitor extends CheckMethodVisitor {
-
- public ForTestCheckMethodVisitor(final ICheckMethodListener listener,
- final String aboluteMethodName) {
- super(listener, aboluteMethodName);
- }
-}
Deleted: trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestCheckMethodVisitor.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestCheckMethodVisitor.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestCheckMethodVisitor.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -1,301 +0,0 @@
-/*
- * Copyright 2011 Luc Peuvrier
- *
- * This file is a part of JOAFIP.
- *
- * JOAFIP is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License.
- *
- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
- * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.gnu.org/licenses/lgpl.html
- *
- * JOAFIP is distributed in the hope that it will be useful, but
- * unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.joafip.store.service.proxy;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-import net.sf.joafip.AbstractJoafipTestCase;
-import net.sf.joafip.TestException;
-import net.sf.joafip.asm.AnnotationVisitor;
-import net.sf.joafip.asm.Attribute;
-import net.sf.joafip.asm.ClassReader;
-import net.sf.joafip.asm.ClassVisitor;
-import net.sf.joafip.asm.FieldVisitor;
-import net.sf.joafip.asm.MethodVisitor;
-import net.sf.joafip.asm.Type;
-import net.sf.joafip.store.entity.proxy.DirectAccessInfo;
-import net.sf.joafip.store.service.bytecode.EnhanceException;
-import net.sf.joafip.store.service.bytecode.proxy.RuntimeEnhanceException;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-public class TestCheckMethodVisitor extends AbstractJoafipTestCase implements
- ClassVisitor {
-
- private transient String className;
-
- private transient CheckMethodListener checkMethodListener;
-
- private transient String methodName;
-
- private transient String methodDescriptor;
-
- public TestCheckMethodVisitor() throws TestException {
- super();
- }
-
- public TestCheckMethodVisitor(final String name) throws TestException {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception { // NOPMD
- checkMethodListener = new CheckMethodListener();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception { // NOPMD
- className = null;// NOPMD
- checkMethodListener = null;// NOPMD
- methodName = null;// NOPMD
- methodDescriptor = null;// NOPMD
- super.tearDown();
- }
-
- public void testDefaultConstructor() throws NoSuchMethodException,
- IOException, EnhanceException {
- check(null, new Class[] {});
- assertFalse("default constructor must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testBooleanConstructor() throws NoSuchMethodException,
- IOException, EnhanceException {
- check(null, new Class[] { boolean.class });
- assertFalse("constructor(boolean) must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testByteConstructor() throws NoSuchMethodException,
- IOException, EnhanceException {
- check(null, new Class[] { byte.class });
- assertFalse("constructor(byte) must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testCharConstructor() throws NoSuchMethodException,
- IOException, EnhanceException {
- check(null, new Class[] { char.class });
- assertFalse("constructor(char) must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testShortConstructor() throws NoSuchMethodException,
- IOException, EnhanceException {
- check(null, new Class[] { short.class });
- assertFalse("constructor(short) must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testIntConstructor() throws NoSuchMethodException, IOException,
- EnhanceException {
- check(null, new Class[] { int.class });
- assertFalse("constructor(int) must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testLongConstructor() throws NoSuchMethodException,
- IOException, EnhanceException {
- check(null, new Class[] { long.class });
- assertFalse("constructor(long) must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testFloatConstructor() throws NoSuchMethodException,
- IOException, EnhanceException {
- check(null, new Class[] { float.class });
- assertFalse("constructor(float) must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testDoubleConstructor() throws NoSuchMethodException,
- IOException, EnhanceException {
- check(null, new Class[] { double.class });
- assertFalse("constructor(double) must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testGetGlobalCount() throws IOException, EnhanceException,
- SecurityException, NoSuchMethodException {
- check("getGlobalCount", new Class[] {});
- assertFalse("getGlobalCount() must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testSetGlobalCount() throws IOException, EnhanceException,
- SecurityException, NoSuchMethodException {
- check("setGlobalCount", new Class[] { int.class });
- assertFalse("setGlobalCount(int) must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testGetaStaticCount() throws IOException, EnhanceException,
- SecurityException, NoSuchMethodException {
- check("getaStaticCount", new Class[] {});
- assertFalse("getaStaticCount() must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testSetaStaticCount() throws IOException, EnhanceException,
- SecurityException, NoSuchMethodException {
- check("setaStaticCount", new Class[] { int.class });
- assertFalse("setaStaticCount(int) must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- public void testWhileOkMethod() throws IOException, EnhanceException,
- SecurityException, NoSuchMethodException {
- check("whileOkMethod", new Class[] {});
- assertFalse("whileOkMethod() must be ok\n" + directAccess(),
- checkMethodListener.hasDirectAccess());
- }
-
- private String directAccess() {
- final StringBuilder stringBuilder = new StringBuilder();
- for (DirectAccessInfo directAccessInfo : checkMethodListener
- .getDirectAccessSet()) {
- stringBuilder.append(directAccessInfo.toString());
- stringBuilder.append('\n');
- stringBuilder.append(checkMethodListener
- .unassembled(directAccessInfo.getMethodAbsoluteName()));
- stringBuilder.append('\n');
- }
- return stringBuilder.toString();
- }
-
- private void check(final String name, final Class<?>[] parameterTypes)
- throws NoSuchMethodException, IOException, EnhanceException {
- if (name == null) {
- setConstructorTotest(parameterTypes);
- } else {
- setMethodTotest(name, parameterTypes);
- }
- final InputStream inputStream = ClassLoader
- .getSystemResourceAsStream("net/sf/joafip/store/service/proxy/ToCheckClass.class");
- final ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
- int byteValue;
- while ((byteValue = inputStream.read()) != -1) {// NOPMD
- byteOutputStream.write(byteValue);
- }
- byteOutputStream.close();
- inputStream.close();
- final byte[] originalCode = byteOutputStream.toByteArray();
- final int off = 0;
- final int len = originalCode.length;
- final ClassReader classreader = new ClassReader(originalCode, off, len);
- try {
- classreader.accept(this, ClassReader.SKIP_FRAMES);
- } catch (RuntimeEnhanceException exception) {
- throw (EnhanceException) exception.getCause();
- }
- if (logger.debugEnabled) {
- logger.debug(checkMethodListener.unassembled());
- }
- }
-
- private void setMethodTotest(final String methodName,
- final Class<?>[] parameterTypes) throws NoSuchMethodException {
- this.methodName = methodName;
- final Method method = ToCheckClass.class.getMethod(methodName,
- parameterTypes);
- methodDescriptor = Type.getMethodDescriptor(method);
- }
-
- private void setConstructorTotest(final Class<?>[] parameterTypes)
- throws NoSuchMethodException {
- methodName = "<init>";
- final Constructor<ToCheckClass> constructor = ToCheckClass.class
- .getConstructor(parameterTypes);
- methodDescriptor = Type.getConstructorDescriptor(constructor);
-
- }
-
- @Override
- public void visit(final int version, final int access, final String name,
- final String signature, final String superName,
- final String[] interfaces) {
- this.className = name;
- }
-
- @Override
- public MethodVisitor visitMethod(final int access, final String name,
- final String desc, final String signature, final String[] exceptions) {
- final ForTestCheckMethodVisitor methodVisitor;
- if (name.equals(methodName) && desc.equals(methodDescriptor)) {
- methodVisitor = new ForTestCheckMethodVisitor(checkMethodListener,
- className + "#" + name + desc);
- } else {
- methodVisitor = null;
- }
- return methodVisitor;
- }
-
- @Override
- public void visitSource(final String source, final String debug) {
- // no implementation
- }
-
- @Override
- public void visitOuterClass(final String owner, final String name,
- final String desc) {
- // no implementation
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(final String desc,
- final boolean visible) {
- // no implementation
- return null;
- }
-
- @Override
- public void visitAttribute(final Attribute attr) {
- // no implementation
- }
-
- @Override
- public void visitInnerClass(final String name, final String outerName,
- final String innerName, final int access) {
- // no implementation
- }
-
- @Override
- public FieldVisitor visitField(final int access, final String name,
- final String desc, final String signature, final Object value) {
- // no implementation
- return null;
- }
-
- @Override
- public void visitEnd() {
- // no implementation
- }
-}
Deleted: trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ToCheckClass.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ToCheckClass.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ToCheckClass.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -1,108 +0,0 @@
-/*
- * Copyright 2011 Luc Peuvrier
- *
- * This file is a part of JOAFIP.
- *
- * JOAFIP is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License.
- *
- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
- * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.gnu.org/licenses/lgpl.html
- *
- * JOAFIP is distributed in the hope that it will be useful, but
- * unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.joafip.store.service.proxy;
-
-/**
- * to check for persistence class
- *
- * @author luc peuvrier
- *
- */
-public class ToCheckClass extends AbstractToCheckClass {
-
- private static int aStaticCount;
-
- private int globalCount;
-
- public ToCheckClass() {
- super();
- }
-
- public ToCheckClass(final boolean booleanValue) {
- super(null, booleanValue);
- }
-
- public ToCheckClass(final byte byteValue) {
- super(null, byteValue);
- }
-
- public ToCheckClass(final char charValue) {
- super(null, charValue);
- }
-
- public ToCheckClass(final short shortValue) {
- super(null, shortValue);
- }
-
- public ToCheckClass(final double doubleValue) {
- super(null, doubleValue);
- }
-
- public ToCheckClass(final float floatValue) {
- super(null, floatValue);
- }
-
- public ToCheckClass(final int intValue) {
- super(null, intValue);
- }
-
- public ToCheckClass(final long longValue) {
- super(null, longValue);
- }
-
- public int getGlobalCount() {
- return globalCount;
- }
-
- public void setGlobalCount(final int globalCount) {
- this.globalCount = globalCount;
- }
-
- public int getaStaticCount() {
- return aStaticCount;
- }
-
- public static void setaStaticCount(final int aStaticCount) {
- ToCheckClass.aStaticCount = aStaticCount;
- }
-
- public void incStaticCount() {
- aStaticCount++;
- }
-
- public void whileOkMethod() {
- int count = 0;
- while (count < 5) {
- globalCount++;
- count++;
- }
- }
-
- public void whileNokMethod(final ToCheckClass toCheckClass) {
- int count = 0;
- while (count < 5) {
- toCheckClass.globalCount++;
- count++;
- }
- }
-}
Modified: trunk/joafip/src/test/resources/log4j.properties
===================================================================
--- trunk/joafip/src/test/resources/log4j.properties 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip/src/test/resources/log4j.properties 2011-10-12 03:04:21 UTC (rev 2917)
@@ -89,7 +89,7 @@
#log4j.logger.net.sf.joafip.store.service.bytecode.ClassEnhancer=debug
#--- tests ---
-#log4j.logger.net.sf.joafip.entity.BobForExport=debug
+log4j.logger.net.sf.joafip.entity.BobForExport=debug
#log4j.logger.net.sf.joafip.heapfile.record.service.TestHeapElementManager=debug
#log4j.logger.net.sf.joafip.heapfile.service.TestHeapDataManager=debug
#log4j.logger.net.sf.joafip.store.service.TestGarbage=debug
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -24,9 +24,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import net.sf.joafip.service.TestExportImport;
-import net.sf.joafip.service.TestExportObject;
-import net.sf.joafip.service.bug.TestRootObjectMapAutoSave;
+import net.sf.joafip.store.service.collection.nosubs.TestStoreCollectionTreeMapNosubsNoG;
/**
*
@@ -43,9 +41,7 @@
public static Test suite() {
final TestSuite suite = new TestSuite("in error Tests");
// $JUnit-BEGIN$
- suite.addTestSuite(TestExportImport.class);
- suite.addTestSuite(TestExportObject.class);
- suite.addTestSuite(TestRootObjectMapAutoSave.class);
+ suite.addTestSuite(TestStoreCollectionTreeMapNosubsNoG.class);
// suite.addTest(xxxx.suite());
// $JUnit-END$
return suite;
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/StoreServiceByteCodeTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/StoreServiceByteCodeTests.java 2011-10-11 04:30:04 UTC (rev 2916)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/StoreServiceByteCodeTests.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -16,10 +16,11 @@
*/
package net.sf.joafip.store.service.bytecode;// NOPMD
+import junit.framework.Test;
+import junit.framework.TestSuite;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.store.service.bytecode.agent.StoreServiceByteCodeAgentTests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import net.sf.joafip.store.service.bytecode.proxy.StoreServiceByteCodeProxyTests;
@NotStorableClass
public class StoreServiceByteCodeTests {
@@ -28,6 +29,7 @@
final TestSuite suite = new TestSuite(
"Test for net.sf.joafip.store.service.bytecode");
// $JUnit-BEGIN$
+ suite.addTest(StoreServiceByteCodeProxyTests.suite());
suite.addTest(StoreServiceByteCodeAgentTests.suite());
suite.addTestSuite(TestForTransform.class);
suite.addTestSuite(TestPersistableCodeGeneratorInStore.class);
Added: trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/proxy/StoreServiceByteCodeProxyTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/proxy/StoreServiceByteCodeProxyTests.java (rev 0)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/proxy/StoreServiceByteCodeProxyTests.java 2011-10-12 03:04:21 UTC (rev 2917)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2009 Luc Peuvrier
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.service.bytecode.proxy;// NOPMD
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import net.sf.joafip.NotStorableClass;
+
+@NotStorableClass
+public class StoreServiceByteCodeProxyTests {
+
+ public static Test suite() {
+ final TestSuite suite = new TestSuite(
+ "Test for net.sf.joafip.store.service.bytecode.agent");
+ // $JUnit-BEGIN$
+ // suite.addTest(StoreServiceBinaryTests.suite());
+ suite.addTestSuite(TestCheckMethodVisitor.class);
+ // $JUnit-END$
+ return suite;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-12 03:04:28
|
Revision: 2917
http://joafip.svn.sourceforge.net/joafip/?rev=2917&view=rev
Author: luc_peuvrier
Date: 2011-10-12 03:04:21 +0000 (Wed, 12 Oct 2011)
Log Message:
-----------
direct field access checker WIP
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumStackEltType.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumType.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNode.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/CheckMethodVisitor.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/ClassConstraintChecker.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/OpcodeInterpreter.java
trunk/joafip/src/test/java/net/sf/joafip/entity/BobForExport.java
trunk/joafip/src/test/java/net/sf/joafip/entity/ClassForExport.java
trunk/joafip/src/test/java/net/sf/joafip/export_import/Container.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionTreeMapNosubsNoG.java
trunk/joafip/src/test/resources/log4j.properties
trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/StoreServiceByteCodeTests.java
Added Paths:
-----------
trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/
trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/AbstractToCheckClass.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/ForTestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/TestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/proxy/ToCheckClass.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/proxy/
trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/bytecode/proxy/StoreServiceByteCodeProxyTests.java
Removed Paths:
-------------
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractToCheckClass.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ForTestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ToCheckClass.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-11 04:30:14
|
Revision: 2916
http://joafip.svn.sourceforge.net/joafip/?rev=2916&view=rev
Author: luc_peuvrier
Date: 2011-10-11 04:30:04 +0000 (Tue, 11 Oct 2011)
Log Message:
-----------
direct field access checker WIP
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
trunk/joafip/src/main/java/net/sf/joafip/service/ClassLoaderProvider.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfoAttributes.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/kept/KeptInMemoryObjectKey.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/kept/SubstituteOfEnum.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/Store.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/ClassEnhancer.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/ClassInfoFactory.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/IClassInfoFactory.java
trunk/joafip/src/test/java/net/sf/joafip/entity/AbstractClassForExport.java
trunk/joafip/src/test/java/net/sf/joafip/entity/BobForExport.java
trunk/joafip/src/test/java/net/sf/joafip/entity/ClassForExport.java
trunk/joafip/src/test/java/net/sf/joafip/entity/rel310/ClassTwo301bReplacement.java
trunk/joafip/src/test/java/net/sf/joafip/export_import/AbstractClassOne301b.java
trunk/joafip/src/test/java/net/sf/joafip/export_import/Bob300.java
trunk/joafip/src/test/java/net/sf/joafip/export_import/ClassOne301b.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/bug/ContrainteForTest.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionArrayListNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionHashMapNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionHashSetNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionHashSetNosubsWithG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionHashTableNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionLinkedHashSetNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionLinkedHashSetNosubsWithG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionLinkedListNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionTreeSetNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionTreeSetNosubsWithG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionTroveHashMapNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionVectorNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/copier/AbstractTestDeepCopier.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/AbstractBobSerialize.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob1.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob1Substitute.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob2.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob3.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/BobString.java
trunk/joafip/src/test/resources/log4j.properties
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/AbstractPLinkedTreeSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/AbstractPTreeSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PArrayList.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PHashMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PHashSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedHashMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedHashSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedList.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PTreeList.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PTreeMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PVector.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/arraylist/ArrayListSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/hash/HashSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/hash/HashSupportNodeSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linked/hash/LinkedHashSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linked/tree/LinkedTreeSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linkedlist/LinkedListSupport.java
trunk/joafip-common/src/main/java/net/sf/joafip/logger/JoafipLogger.java
Added Paths:
-----------
trunk/joafip/doc/byte_code_control_flow.txt
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/DirectAccessInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumStackEltType.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumType.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNode.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeAloadThis.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2X1.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2X2.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDupX1.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDupX2.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeGet.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeLdc.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeMethod.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeMultiANewArray.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePop.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePop2.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePut.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeSwap.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/StackElement.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/CheckMethodVisitor.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/ClassConstraintChecker.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/ICheckMethodListener.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/OpcodeInterpreter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/RuntimeEnhanceException.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/CheckMethodListener.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractToCheckClass.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ForTestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ToCheckClass.java
Modified: trunk/joafip/doc/_todo.txt
===================================================================
--- trunk/joafip/doc/_todo.txt 2011-10-03 03:24:41 UTC (rev 2915)
+++ trunk/joafip/doc/_todo.txt 2011-10-11 04:30:04 UTC (rev 2916)
@@ -21,6 +21,7 @@
- project divided on sub project
- export speed up
- kept in memory for object referenced by static field
+- check field access constraints, direct field access disallow to force use of getter and/or setter
minor changes:
- added search last in red black tree manager
@@ -75,8 +76,32 @@
currently:
-------------------------------------------------------------------------------------
+persistence constraint check at enhancement for proxy creation
+==> update http://joafip.sourceforge.net/presentation/ppojo.html#prules
+- check done at enhancement -> exception
+- private are intercepted, correct the doc
+
+upgrade Maven plugins :
+maven-jar-plugin ..................................... 2.3.1 -> 2.3.2
+[INFO] maven-javadoc-plugin ..................................... 2.7 -> 2.8
+[INFO] maven-release-plugin ................................... 2.1 -> 2.2.1
+[INFO] org.codehaus.mojo:build-helper-maven-plugin .............. 1.5 -> 1.7
+[INFO] org.codehaus.mojo:buildnumber-maven-plugin ........ 1.0-beta-4 -> 1.0
+[INFO] org.codehaus.mojo:exec-maven-plugin .................... 1.2 -> 1.2.1
+
+
export/import problem.
+garbage management error with jhupedom
+
+keptinmemory problem
+
+static field persistence problem
+
+joafip reflect project (see setAccessible )
+- joafip
+- joafip-log4j
+
changes for garbage management because of autosave
- tests to add
- test for state machine
@@ -96,6 +121,7 @@
a java agent to change "new Xxx" to call to newInstance proxied object factory for auto save
+collection apache and google
-------------------------------------------------------------------------------------
copier:
- case of enum field
Added: trunk/joafip/doc/byte_code_control_flow.txt
===================================================================
--- trunk/joafip/doc/byte_code_control_flow.txt (rev 0)
+++ trunk/joafip/doc/byte_code_control_flow.txt 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,109 @@
+Determining Basic Blocks
+We can use the following rules to determine the basic
+blocks, that is, by finding the set of leaders.
+
+- The first instruction of the method and each first
+instruction of every handler for the method are
+leaders.
+
+- Each instruction that is the target of an uncondi-
+tional branch (goto, goto_w, jsr, jsr_w, and ret)
+is a leader.
+
+- Each instruction that is the target of a condi-
+tional branch (ifeq, iflt, ifle, ifne, ifgt,
+ifge, ifnull, ifnonnull, if_icmpeq, if_icmpne,
+if_icmplt, if_icmpgt, if_icmple, if_icmpge,
+if_acmpeq, if_acmpne, lcmp, fcmpl, fcmpg,
+dcmpl, dcmpg) is a leader.
+
+- Each instruction that is one of the target of a
+compound conditional branch (tableswitch or
+lookupswitch) is a leader.
+
+- Each instruction that immediately follows a con-
+ditional or unconditional branch, or a <T>return
+(ireturn, lreturn, freturn, dreturn, areturn,
+and return), or a compound conditional branch
+instruction is a leader.
+
+- Now, each individual leader give rise to a basic block,
+consisting of all instructions up to the next leader or
+the end of the bytecode. Furthermore, we enclose each
+method invocation (invokevirtual, invokespecial,
+invokestatic, and invokeinterface) in a basic block
+of its own.
+
+
+ ----
+
+unconditional branch
+* goto
+* goto_w
+* jsr
+* jsr_w
+* ret end
+
+conditional branch
+* ifeq
+* iflt
+* ifle
+* ifne
+* ifgt,
+* ifge
+* ifnull
+* ifnonnull
+* if_icmpeq
+* if_icmpne
+* if_icmplt
+* if_icmpgt
+* if_icmple
+* if_icmpge
+* if_acmpeq
+* if_acmpne
+
+lcmp ? not a jump
+fcmpl ? not a jump
+fcmpg ? not a jump
+dcmpl ? not a jump
+dcmpg ? not a jump
+
+
+compound conditional branch
+* tableswitch end
+* lookupswitch end
+
+* ireturn end
+* lreturn end
+* freturn end
+* dreturn end
+* areturn end
+* return end
+* throw end ? missing
+
+Building the CFGs
+-----------------
+
+Once we divide instructions of a method into basic
+blocks, we can use the following rules to construct the
+CFG for the method. Let u 2 V and v 2 V be two basic
+blocks:
+
+An arc (u; v) is added to A if v follows u in the byte-
+code and u does not terminate in a unconditional
+branch.
+
+An arc (u; v) is added to A if the last instruction
+of u is a conditional or unconditional branch to the
+first instruction in v.
+
+An arc id added an arc (u; v) to A from the basic
+block of each tableswitch or lookupswitch to the
+basic block of each instruction that is defined as the
+target in the switch.
+
+For each subroutine call, two arcs are added to A:
+one from the basic block of the jsr or jsr_w to the
+basic block of target, and one from the basic block
+containing the corresponding ret to the basic block
+of the instruction that immediately follows the call.
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java 2011-10-03 03:24:41 UTC (rev 2915)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -16,6 +16,8 @@
*/
package net.sf.joafip.service;//NOPMD
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
@@ -648,6 +650,22 @@
}
@Override
+ public void addNotCheckedMethod(final Method method) {
+ store.addNotCheckedMethod(method);
+ }
+
+ @Override
+ public void addNotCheckedMethod(final Constructor<?> constructor) {
+ store.addNotCheckedMethod(constructor);
+ }
+
+ @Override
+ public void addNotCheckedMethod(final String objectClassName,
+ final String absoluteMethodName) {
+ store.addNotCheckedMethod(objectClassName, absoluteMethodName);
+ }
+
+ @Override
public void setObjectIOForClass(final Class<?> objectClass,
final Class<? extends IObjectInput> objectInputClass,
final Class<? extends IObjectOutput> objectOutputClass)
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/ClassLoaderProvider.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/ClassLoaderProvider.java 2011-10-03 03:24:41 UTC (rev 2915)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/ClassLoaderProvider.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -23,6 +23,7 @@
package net.sf.joafip.service;
import java.io.File;
+import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
@@ -95,6 +96,7 @@
if (toUseClassLoader == null || url == null) {
url = ClassLoader.getSystemResource(resourceName);
}
+
if (url == null) {
final URI uri = new File(resourceName).toURI();
url = uri.toURL();
@@ -102,6 +104,29 @@
return url;
}
+ public InputStream getResourceAsStream(final String resourceName) {
+ ClassLoader toUseClassLoader;
+ InputStream inputStream = null;
+ if (classLoader == null) {
+ toUseClassLoader = getCurrentThreadContextClassLoader();
+ if (toUseClassLoader != null) {
+ inputStream = toUseClassLoader
+ .getResourceAsStream(resourceName);
+ }
+ } else {
+ toUseClassLoader = classLoader;
+ inputStream = toUseClassLoader.getResourceAsStream(resourceName);
+ }
+ if (toUseClassLoader == null || inputStream == null) {
+ toUseClassLoader = ClassLoader.getSystemClassLoader();
+ inputStream = toUseClassLoader.getResourceAsStream(resourceName);
+ }
+ if (toUseClassLoader == null || inputStream == null) {
+ inputStream = toUseClassLoader.getResourceAsStream(resourceName);
+ }
+ return inputStream;
+ }
+
/**
* Get the Thread Context Loader which is a JDK 1.2 feature. If we are
* running under JDK 1.1 or anything else goes wrong the
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2011-10-03 03:24:41 UTC (rev 2915)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -16,6 +16,8 @@
*/
package net.sf.joafip.service;//NOPMD
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
@@ -610,6 +612,12 @@
*/
void setForceEnhance(String[] objectClassNames);
+ void addNotCheckedMethod(Method method);
+
+ void addNotCheckedMethod(Constructor<?> constructor);
+
+ void addNotCheckedMethod(String objectClassName, String absoluteMethodName);
+
/**
* set object input output manager for a class<br>
* if class not accessible see {@link #setObjectIOForClass(String, Class)}<br>
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfo.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfo.java 2011-10-03 03:24:41 UTC (rev 2915)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfo.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -32,7 +32,9 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.TreeMap;
+import java.util.TreeSet;
import net.sf.joafip.DeprecatedInStoreClass;
import net.sf.joafip.NotStorableClass;
@@ -271,6 +273,8 @@
private final Exception creationTrace = new Exception("creation trace");
+ private final Set<String> notCheckedMethodSet = new TreeSet<String>();
+
/**
*
* @param objectClass
@@ -932,6 +936,10 @@
forceEnhance = true;
}
+ public void addNotCheckedMethod(final String absoluteMethodName) {
+ notCheckedMethodSet.add(absoluteMethodName);
+ }
+
public void setSubstitute(final ClassInfo substituteClassInfo,
final ISubstituteObjectManager substituteObjectManager) {
substituted = true;
@@ -966,6 +974,10 @@
return forceEnhance;
}
+ public Set<String> getNotCheckedMethod() {
+ return notCheckedMethodSet;
+ }
+
public boolean isNotStorable() {
return notStorable;
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfoAttributes.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfoAttributes.java 2011-10-03 03:24:41 UTC (rev 2915)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfoAttributes.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -22,6 +22,9 @@
*/
package net.sf.joafip.store.entity.classinfo;
+import java.util.Set;
+import java.util.TreeSet;
+
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.store.service.objectio.manager.ISubsituteSynchronizer;
import net.sf.joafip.store.service.objectio.manager.ISubstituteObjectManager;
@@ -54,6 +57,8 @@
private boolean forceEnhance;
+ private final Set<String> notCheckedMethodSet = new TreeSet<String>();
+
private Class<?> substituteObjectClass;
private ISubstituteObjectManager substituteObjectManager;
@@ -136,10 +141,18 @@
forceEnhance = true;
}
+ public void addNotCheckedMethod(final String absoluteMethodName) {
+ notCheckedMethodSet.add(absoluteMethodName);
+ }
+
public boolean isForceEnhance() {
return forceEnhance;
}
+ public Set<String> getNotCheckedMethodSet() {
+ return notCheckedMethodSet;
+ }
+
public void setSubstituteObjectManager(
final Class<?> substituteObjectClass,
final ISubstituteObjectManager substituteObjectManager) {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/kept/KeptInMemoryObjectKey.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/kept/KeptInMemoryObjectKey.java 2011-10-03 03:24:41 UTC (rev 2915)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/kept/KeptInMemoryObjectKey.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -67,9 +67,9 @@
// return false;
final KeptInMemoryObjectKey other = (KeptInMemoryObjectKey) obj;
if (key == null) {
- if (other.key != null)
+ if (other.getKey() != null)
return false;
- } else if (!key.equals(other.key))
+ } else if (!key.equals(other.getKey()))
return false;
return true;
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/kept/SubstituteOfEnum.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/kept/SubstituteOfEnum.java 2011-10-03 03:24:41 UTC (rev 2915)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/kept/SubstituteOfEnum.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -57,9 +57,9 @@
@Override
public int compareTo(final SubstituteOfEnum other) {
- int compareTo = enumClassName.compareTo(other.enumClassName);
+ int compareTo = enumClassName.compareTo(other.getEnumClassName());
if (compareTo == 0) {
- compareTo = enumName.compareTo(other.enumName);
+ compareTo = enumName.compareTo(other.getEnumName());
}
return compareTo;
}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/DirectAccessInfo.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/DirectAccessInfo.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/DirectAccessInfo.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class DirectAccessInfo implements Comparable<DirectAccessInfo> {
+
+ private final String methodAbsoluteName;
+
+ private final String labeledAddress;
+
+ private final int sourceLineNumber;
+
+ public DirectAccessInfo(final String methodAbsoluteName,
+ final String labeledAddress, final int sourceLineNumber) {
+ super();
+ this.methodAbsoluteName = methodAbsoluteName;
+ this.labeledAddress = labeledAddress;
+ this.sourceLineNumber = sourceLineNumber;
+ }
+
+ public String getMethodAbsoluteName() {
+ return methodAbsoluteName;
+ }
+
+ public String getLabeledAddress() {
+ return labeledAddress;
+ }
+
+ public int getSourceLineNumber() {
+ return sourceLineNumber;
+ }
+
+ @Override
+ public String toString() {
+ return "in \"" + methodAbsoluteName + "\" opcode at " + labeledAddress
+ + ", source line number " + sourceLineNumber;
+ }
+
+ @Override
+ public int compareTo(final DirectAccessInfo other) {
+ int compareTo = methodAbsoluteName.compareTo(other
+ .getMethodAbsoluteName());
+ if (compareTo == 0) {
+ compareTo = sourceLineNumber - other.getSourceLineNumber();
+ }
+ return compareTo;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime
+ * result
+ + ((methodAbsoluteName == null) ? 0 : methodAbsoluteName
+ .hashCode());
+ result = prime * result + sourceLineNumber;
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return compareTo((DirectAccessInfo) obj) == 0;
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumStackEltType.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumStackEltType.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumStackEltType.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public enum EnumStackEltType {
+ /** no type */
+ VOID(0),
+ /** reference on object or array */
+ REF(1),
+ /**/
+ INT_SHORT_CHAR_BYTE_BOOL(1),
+ /**/
+ LONG_L(2), LONG_H(2),
+ /**/
+ FLOAT(1),
+ /**/
+ DOUBLE_L(2), DOUBLE_H(2),
+ /**/
+ OPCODE_ADDRESS(0);
+
+ private final int category;
+
+ private EnumStackEltType(final int category) {
+ this.category = category;
+ }
+
+ public int getCategory() {
+ return category;
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumType.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumType.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumType.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public enum EnumType {
+ /** no type */
+ VOID(0, EnumStackEltType.VOID, null),
+ /** reference on object or array */
+ REF(1, EnumStackEltType.REF, null),
+ /**/
+ INT(1, EnumStackEltType.INT_SHORT_CHAR_BYTE_BOOL, null),
+ /**/
+ LONG(2, EnumStackEltType.LONG_L, EnumStackEltType.LONG_H),
+ /**/
+ FLOAT(1, EnumStackEltType.FLOAT, null),
+ /**/
+ DOUBLE(2, EnumStackEltType.DOUBLE_L, EnumStackEltType.DOUBLE_H),
+ /**/
+ SHORT(1, EnumStackEltType.INT_SHORT_CHAR_BYTE_BOOL, null),
+ /**/
+ CHAR(1, EnumStackEltType.INT_SHORT_CHAR_BYTE_BOOL, null),
+ /**/
+ BYTE_BOOL(1, EnumStackEltType.INT_SHORT_CHAR_BYTE_BOOL, null),
+ /**/
+ OPCODE_ADDRESS(0, EnumStackEltType.OPCODE_ADDRESS, null);
+
+ private final int category;
+
+ private final EnumStackEltType lowType;
+
+ private final EnumStackEltType highType;
+
+ private EnumType(final int category, final EnumStackEltType lowType,
+ final EnumStackEltType highType) {
+ this.category = category;
+ this.lowType = lowType;
+ this.highType = highType;
+ }
+
+ public int getCategory() {
+ return category;
+ }
+
+ public EnumStackEltType getLowType() {
+ return lowType;
+ }
+
+ public EnumStackEltType getHighType() {
+ return highType;
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNode.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNode.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNode.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.asm.Label;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+import net.sf.joafip.store.service.bytecode.proxy.OpcodeInterpreter;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNode {
+
+ protected final static OpcodeInterpreter OPCODE_INTERPRETER = OpcodeInterpreter
+ .getInstance();
+
+ private final List<OpcodeNode> nextOpcodeNodeList = new LinkedList<OpcodeNode>();
+
+ private final int address;
+
+ protected final int opcode;
+
+ private final int lineNumber;
+
+ private StackElement beforeExecutionStackElement;
+
+ private StackElement afterExecutionStackElement;
+
+ private Label label;
+
+ /**
+ * construct a null opcode node
+ */
+ public OpcodeNode() {
+ super();
+ this.opcode = -1;
+ this.lineNumber = 0;
+ this.address = -1;
+ }
+
+ public OpcodeNode(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode) {
+ super();
+ this.opcode = opcode;
+ this.address = address;
+ this.lineNumber = lineNumber;
+ if (previousOpcode != null) {
+ previousOpcode.addNext(this);
+ }
+ }
+
+ public String getLabeledAddress() {
+ return (label == null ? "" : label.toString()) + "@" + address;
+ }
+
+ public int getAddress() {
+ return address;
+ }
+
+ public Label getLabel() {
+ return label;
+ }
+
+ public void setLabel(final Label label) {
+ this.label = label;
+ }
+
+ public void setBeforeExecutionStackElement(
+ final StackElement beforeExecutionStackElement) {
+ assert this.beforeExecutionStackElement == null;
+ this.beforeExecutionStackElement = beforeExecutionStackElement;
+ }
+
+ public StackElement getBeforeExecutionStackElement() {
+ return beforeExecutionStackElement;
+ }
+
+ public StackElement getAfterExecutionStackElement() {
+ return afterExecutionStackElement;
+ }
+
+ public void addNext(final OpcodeNode next) {
+ nextOpcodeNodeList.add(next);
+ }
+
+ public List<OpcodeNode> getNextOpcodeNodeList() {
+ return nextOpcodeNodeList;
+ }
+
+ public StackElement interprete() throws EnhanceException {
+ afterExecutionStackElement = interprete(beforeExecutionStackElement);
+ return afterExecutionStackElement;
+ }
+
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ return OPCODE_INTERPRETER.interprete(opcode, currentStackElement);
+ }
+
+ public boolean isDirectAccess() {
+ return false;
+ }
+
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder stringBuilder = new StringBuilder();
+ if (label != null) {
+ stringBuilder.append(label.toString());
+ }
+ stringBuilder.append('@');
+ stringBuilder.append(address);
+ stringBuilder.append(" opcode #");
+ stringBuilder.append(opcode);
+ stringBuilder.append(' ');
+ stringBuilder.append(mnemonic());
+ stringBuilder.append(" line #");
+ stringBuilder.append(lineNumber);
+ stringBuilder.append(" next ");
+ for (OpcodeNode next : nextOpcodeNodeList) {
+ final Label nextLabel = next.label;
+ if (nextLabel != null) {
+ stringBuilder.append(nextLabel.toString());
+ }
+ stringBuilder.append('@');
+ stringBuilder.append(next.address);
+ stringBuilder.append(' ');
+ }
+ stringBuilder.append('\n');
+ if (beforeExecutionStackElement == null) {
+ stringBuilder.append('?');
+ } else {
+ stringBuilder.append(beforeExecutionStackElement.toString());
+ }
+ stringBuilder.append("\n=> ");
+ if (afterExecutionStackElement == null) {
+ stringBuilder.append('?');
+ } else {
+ stringBuilder.append(afterExecutionStackElement.toString());
+ }
+ return stringBuilder.toString();
+ }
+
+ protected String mnemonic() {
+ return OPCODE_INTERPRETER.mnemonic(opcode);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeAloadThis.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeAloadThis.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeAloadThis.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodeAloadThis extends OpcodeNode {
+
+ public OpcodeNodeAloadThis(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode) {
+ super(opcode, address, lineNumber, previousOpcode);
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ final StackElement stackElement = super.interprete(currentStackElement);
+ assert stackElement != null : "must has stack element for opcode "
+ + opcode;
+ assert EnumStackEltType.REF.equals(stackElement.getType());
+ stackElement.setIsThisRef();
+ return stackElement;
+ }
+
+ @Override
+ protected String mnemonic() {
+ return super.mnemonic() + " THIS";
+ }
+
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodeDup extends OpcodeNode {
+
+ public OpcodeNodeDup(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode) {
+ super(opcode, address, lineNumber, previousOpcode);
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ return OPCODE_INTERPRETER.interpreteDup(currentStackElement);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodeDup2 extends OpcodeNode {
+
+ public OpcodeNodeDup2(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode) {
+ super(opcode, address, lineNumber, previousOpcode);
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ return OPCODE_INTERPRETER.interpreteDup2(currentStackElement);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2X1.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2X1.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2X1.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodeDup2X1 extends OpcodeNode {
+
+ public OpcodeNodeDup2X1(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode) {
+ super(opcode, address, lineNumber, previousOpcode);
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ return OPCODE_INTERPRETER.interpreteDup2X1(currentStackElement);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2X2.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2X2.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2X2.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodeDup2X2 extends OpcodeNode {
+
+ public OpcodeNodeDup2X2(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode) {
+ super(opcode, address, lineNumber, previousOpcode);
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ return OPCODE_INTERPRETER.interpreteDup2X2(currentStackElement);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDupX1.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDupX1.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDupX1.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodeDupX1 extends OpcodeNode {
+
+ public OpcodeNodeDupX1(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode) {
+ super(opcode, address, lineNumber, previousOpcode);
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ return OPCODE_INTERPRETER.interpreteDupX1(currentStackElement);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDupX2.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDupX2.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDupX2.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodeDupX2 extends OpcodeNode {
+
+ public OpcodeNodeDupX2(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode) {
+ super(opcode, address, lineNumber, previousOpcode);
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ return OPCODE_INTERPRETER.interpreteDupX2(currentStackElement);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeGet.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeGet.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeGet.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.asm.Opcodes;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodeGet extends OpcodeNode {
+
+ private final String desc;
+
+ private boolean directAccess;
+
+ public OpcodeNodeGet(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode,
+ final String desc) {
+ super(opcode, address, lineNumber, previousOpcode);
+ this.desc = desc;
+ }
+
+ @Override
+ public boolean isDirectAccess() {
+ return directAccess;
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ final StackElement pointer;
+ if (opcode == Opcodes.GETFIELD) {
+ pointer = OPCODE_INTERPRETER.pop(currentStackElement, EnumType.REF);
+ directAccess = true ^ currentStackElement.isThisReference();
+ } else {
+ pointer = currentStackElement;
+ directAccess = false;
+ }
+ return OPCODE_INTERPRETER.push(desc, pointer);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeLdc.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeLdc.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeLdc.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodeLdc extends OpcodeNode {
+
+ private final Object cst;
+
+ public OpcodeNodeLdc(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode,
+ final Object cst) {
+ super(opcode, address, lineNumber, previousOpcode);
+ this.cst = cst;
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ return OPCODE_INTERPRETER.interpreteLdc(cst, currentStackElement);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeMethod.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeMethod.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeMethod.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodeMethod extends OpcodeNode {
+
+ private final String desc;
+
+ public OpcodeNodeMethod(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode,
+ final String desc) {
+ super(opcode, address, lineNumber, previousOpcode);
+ this.desc = desc;
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ return OPCODE_INTERPRETER.interpreteInvoke(opcode, desc,
+ currentStackElement);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeMultiANewArray.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeMultiANewArray.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeMultiANewArray.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodeMultiANewArray extends OpcodeNode {
+
+ private final int dims;
+
+ public OpcodeNodeMultiANewArray(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode,
+ final int dims) {
+ super(opcode, address, lineNumber, previousOpcode);
+ this.dims = dims;
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ return OPCODE_INTERPRETER.multiANewArray(dims, currentStackElement);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePop.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePop.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePop.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.store.service.bytecode.EnhanceException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class OpcodeNodePop extends OpcodeNode {
+
+ public OpcodeNodePop(final int opcode, final int address,
+ final int lineNumber, final OpcodeNode previousOpcode) {
+ super(opcode, address, lineNumber, previousOpcode);
+ }
+
+ @Override
+ protected StackElement interprete(final StackElement currentStackElement)
+ throws EnhanceException {
+ return OPCODE_INTERPRETER.interpretePop(currentStackElement);
+ }
+}
Added: trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePop2.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePop2.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePop2.java 2011-10-11 04:30:04 UTC (rev 2916)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.stor...
[truncated message content] |
|
From: <luc...@us...> - 2011-10-11 04:30:12
|
Revision: 2916
http://joafip.svn.sourceforge.net/joafip/?rev=2916&view=rev
Author: luc_peuvrier
Date: 2011-10-11 04:30:04 +0000 (Tue, 11 Oct 2011)
Log Message:
-----------
direct field access checker WIP
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
trunk/joafip/src/main/java/net/sf/joafip/service/ClassLoaderProvider.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfoAttributes.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/kept/KeptInMemoryObjectKey.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/kept/SubstituteOfEnum.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/Store.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/ClassEnhancer.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/ClassInfoFactory.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/IClassInfoFactory.java
trunk/joafip/src/test/java/net/sf/joafip/entity/AbstractClassForExport.java
trunk/joafip/src/test/java/net/sf/joafip/entity/BobForExport.java
trunk/joafip/src/test/java/net/sf/joafip/entity/ClassForExport.java
trunk/joafip/src/test/java/net/sf/joafip/entity/rel310/ClassTwo301bReplacement.java
trunk/joafip/src/test/java/net/sf/joafip/export_import/AbstractClassOne301b.java
trunk/joafip/src/test/java/net/sf/joafip/export_import/Bob300.java
trunk/joafip/src/test/java/net/sf/joafip/export_import/ClassOne301b.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/bug/ContrainteForTest.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionArrayListNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionHashMapNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionHashSetNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionHashSetNosubsWithG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionHashTableNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionLinkedHashSetNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionLinkedHashSetNosubsWithG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionLinkedListNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionTreeSetNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionTreeSetNosubsWithG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionTroveHashMapNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/collection/nosubs/TestStoreCollectionVectorNosubsNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/copier/AbstractTestDeepCopier.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/AbstractBobSerialize.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob1.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob1Substitute.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob2.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob3.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/BobString.java
trunk/joafip/src/test/resources/log4j.properties
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/AbstractPLinkedTreeSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/AbstractPTreeSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PArrayList.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PHashMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PHashSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedHashMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedHashSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedList.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PTreeList.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PTreeMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PVector.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/arraylist/ArrayListSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/hash/HashSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/hash/HashSupportNodeSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linked/hash/LinkedHashSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linked/tree/LinkedTreeSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linkedlist/LinkedListSupport.java
trunk/joafip-common/src/main/java/net/sf/joafip/logger/JoafipLogger.java
Added Paths:
-----------
trunk/joafip/doc/byte_code_control_flow.txt
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/DirectAccessInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumStackEltType.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/EnumType.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNode.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeAloadThis.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2X1.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDup2X2.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDupX1.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeDupX2.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeGet.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeLdc.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeMethod.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeMultiANewArray.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePop.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePop2.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodePut.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/OpcodeNodeSwap.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/proxy/StackElement.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/CheckMethodVisitor.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/ClassConstraintChecker.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/ICheckMethodListener.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/OpcodeInterpreter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/RuntimeEnhanceException.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/CheckMethodListener.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractToCheckClass.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ForTestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestCheckMethodVisitor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ToCheckClass.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-03 03:24:49
|
Revision: 2915
http://joafip.svn.sourceforge.net/joafip/?rev=2915&view=rev
Author: luc_peuvrier
Date: 2011-10-03 03:24:41 +0000 (Mon, 03 Oct 2011)
Log Message:
-----------
after check for static field persistence
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java
trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/AbstractExporter.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob1.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/manager/TestObjectIOManagerStaticFieldCase.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/ObjectIOStaticTest.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
Modified: trunk/joafip/doc/_todo.txt
===================================================================
--- trunk/joafip/doc/_todo.txt 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/doc/_todo.txt 2011-10-03 03:24:41 UTC (rev 2915)
@@ -20,6 +20,7 @@
- java agent changed
- project divided on sub project
- export speed up
+- kept in memory for object referenced by static field
minor changes:
- added search last in red black tree manager
@@ -74,6 +75,8 @@
currently:
-------------------------------------------------------------------------------------
+export/import problem.
+
changes for garbage management because of autosave
- tests to add
- test for state machine
Modified: trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -166,6 +166,9 @@
* static fields
*/
if (!Modifier.isFinal(modifiers)) {
+ /*
+ * only not final field can be acceded
+ */
staticFieldInfoList.add(fieldInfo);
}
} else {
@@ -280,6 +283,7 @@
if (fieldInfo.isFieldDefined()) {
field = fieldInfo.getField();
} else {
+ // FIXMELUC ________why this case field undefined
try {
final Class<?> clazz = fieldInfo.getDeclaringClass();
final String fieldName = fieldInfo.getFieldName();
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -1188,6 +1188,26 @@
}
@Override
+ public void referencedByPesistedStaticField(
+ final Class<?> classHavingStaticFieldReferenced)
+ throws FilePersistenceException {
+ try {
+ store.referencedByPesistedStaticField(classHavingStaticFieldReferenced);
+ } catch (final StoreException exception) {
+ throw new FilePersistenceException(exception);
+ }
+ }
+
+ @Override
+ public void referencedByPesistedStaticField(
+ final Class<?>[] classHavingStaticFieldReferenced)
+ throws FilePersistenceException {
+ for (Class<?> clazz : classHavingStaticFieldReferenced) {
+ referencedByPesistedStaticField(clazz);
+ }
+ }
+
+ @Override
public String keyOfObjectKeptInMemory(final Object object) {
return store.keyOfObjectKeptInMemory(object);
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -1204,6 +1204,16 @@
void keptInMemory(final String key, final Object object)
throws FilePersistenceException;
+ // FIXMELUC _______________javadoc
+ void referencedByPesistedStaticField(
+ Class<?> classHavingStaticFieldReferenced)
+ throws FilePersistenceException;
+
+ // FIXMELUC _______________javadoc
+ void referencedByPesistedStaticField(
+ Class<?>[] classHavingStaticFieldReferenced)
+ throws FilePersistenceException;
+
/**
*
* @param object
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -42,8 +42,6 @@
public StoreSynchro() { // NOPMD
super();
- // FIXMELUC _____________________for test
- Thread.dumpStack();
}
public void setPersistenceId(final int persistenceId) {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfo.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfo.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfo.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -36,7 +36,7 @@
private static final String NOT_DEFINED = "not defined:\n";
- private static final DoPrivilegedSetFieldAccessible setFieldAccessible = // NOPMD
+ private static final DoPrivilegedSetFieldAccessible SET_FIELD_ACCESSIBLE =
/**/DoPrivilegedSetFieldAccessible.getInstance();
public static final FieldInfo NULL = new FieldInfo();
@@ -104,7 +104,7 @@
public FieldInfo(final Field field, final ClassInfo declaringClass,
final ClassInfo fieldType) throws ClassInfoException {
this.field = field;
- setFieldAccessible.set(field);
+ SET_FIELD_ACCESSIBLE.set(field);
this.fieldType = fieldType;
primitiveType = fieldType.isPrimitiveType();
basicType = fieldType.isBasicType();
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -36,6 +36,7 @@
import net.sf.joafip.store.entity.StoreHeader;
import net.sf.joafip.store.entity.StoreSynchro;
import net.sf.joafip.store.entity.classinfo.ClassInfo;
+import net.sf.joafip.store.entity.classinfo.FieldInfo;
import net.sf.joafip.store.entity.heaprecordable.IHeapRecordable;
import net.sf.joafip.store.entity.kept.KeptInMemoryObjectKey;
import net.sf.joafip.store.entity.kept.SubstituteOfEnum;
@@ -587,6 +588,7 @@
} catch (final ClassInfoException exception) {
throw new StoreException(exception);
}
+ // FIXMELUC _______________________not good classInfo.setKeptInMemory()
classInfo.setKeptInMemory();
setSubstituteObjectManager(objectClass, KeptInMemoryObjectKey.class,
keptInMemorySubstituteObjectManager);
@@ -594,6 +596,34 @@
}
@Override
+ public void referencedByPesistedStaticField(
+ final Class<?> classHavingStaticFieldReferenced)
+ throws StoreException {
+ ClassInfo classInfo;
+ try {
+ classInfo = classInfoFactory
+ .getNoProxyClassInfo(classHavingStaticFieldReferenced);
+ final FieldInfo[] fieldsInfo = classInfo
+ .getAllDeclaredStaticFields();
+ for (FieldInfo fieldInfo : fieldsInfo) {
+ final Object value = helperReflect.getFieldValue(null,
+ fieldInfo, true);
+ final StringBuilder keyBuilder = new StringBuilder();// NOPMD
+ keyBuilder.append(classInfo.getName());
+ keyBuilder.append('#');
+ keyBuilder.append(fieldInfo.getDeclaringClassInfo().getName());
+ keyBuilder.append('#');
+ keyBuilder.append(fieldInfo.getFieldName());
+ keptInMemory(keyBuilder.toString(), value);
+ }
+ } catch (final ClassInfoException exception) {
+ throw new StoreException(exception);
+ } catch (ReflectException exception) {
+ throw new StoreException(exception);
+ }
+ }
+
+ @Override
public void storedImmutableEnum(final Class<? extends Enum<?>> enumClass)
throws StoreException {
setSubstituteObjectManager(enumClass, SubstituteOfEnum.class,
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -686,6 +686,9 @@
void keptInMemory(String key, Object object) throws StoreException;
+ void referencedByPesistedStaticField(
+ Class<?> classHavingStaticFieldReferenced) throws StoreException;
+
String keyOfObjectKeptInMemory(Object object);
void setRecordSaveActions(boolean recordActions);
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/AbstractExporter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/AbstractExporter.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/AbstractExporter.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -67,7 +67,7 @@
final protected JoafipLogger logger = JoafipLogger.getLogger(getClass());// NOPMD
- private final static DoPrivilegedSetFieldAccessible setFieldAccessible = // NOPMD
+ private final static DoPrivilegedSetFieldAccessible SET_FIELD_ACCESSIBLE =
/**/DoPrivilegedSetFieldAccessible.getInstance();
final private static HelperReflect helperReflect = HelperReflect// NOPMD
@@ -609,7 +609,7 @@
for (final FieldInfo fieldInfo : fieldInfos) {
if (fieldInfo.isPersisted()) {
final Field field = fieldInfo.getField();
- setFieldAccessible.set(field);
+ SET_FIELD_ACCESSIBLE.set(field);
final Object fieldValue;
fieldValue = field.get(null);
final ClassInfo fieldClassInfo = fieldInfo
@@ -667,7 +667,7 @@
for (final FieldInfo fieldInfo : fieldInfos) {
if (fieldInfo.isPersisted()) {
final Field field = fieldInfo.getField();
- setFieldAccessible.set(field);
+ SET_FIELD_ACCESSIBLE.set(field);
final Object fieldValue;
fieldValue = field.get(object);
final ClassInfo fieldClassInfo = fieldInfo
@@ -725,7 +725,7 @@
// <<<<<<< .working
if (fieldInfo.isPersisted()) {
final Field field = fieldInfo.getField();
- setFieldAccessible.set(field);
+ SET_FIELD_ACCESSIBLE.set(field);
final Object fieldValue;
fieldValue = field.get(object);
final ClassInfo fieldClassInfo = fieldInfo
@@ -1059,7 +1059,7 @@
// <<<<<<< .working
if (fieldInfo.isPersisted()) {
final Field field = fieldInfo.getField();
- setFieldAccessible.set(field);
+ SET_FIELD_ACCESSIBLE.set(field);
final Object fieldValue;
fieldValue = field.get(enumObject);
final ClassInfo fieldClassInfo = fieldInfo
@@ -1117,7 +1117,7 @@
for (final FieldInfo fieldInfo : fieldInfos) {
if (fieldInfo.isPersisted()) {
final Field field = fieldInfo.getField();
- setFieldAccessible.set(field);
+ SET_FIELD_ACCESSIBLE.set(field);
final Object fieldValue;
fieldValue = field.get(enumObject);
final ClassInfo fieldClassInfo = fieldInfo
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -25,6 +25,7 @@
import java.util.Map;
import net.sf.joafip.StorableClass;
+import net.sf.joafip.java.util.PTreeMap;
/**
*
@@ -44,6 +45,12 @@
map.put(EMPTY.getKey(), EMPTY);
}
+ private static final Map<String, String> MAP2 = new PTreeMap<String, String>();
+
+ static {
+ MAP2.put("1", "xxx");
+ }
+
private final String key;
public PersistableWithStaticField(final String key) {
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -54,18 +54,51 @@
}
@SuppressWarnings("PMD")
- public void test() throws FilePersistenceException,
+ public void testReferencedStaticField() throws FilePersistenceException,
FilePersistenceInvalidClassException,
FilePersistenceNotSerializableException,
FilePersistenceClassNotFoundException,
FilePersistenceDataCorruptedException,
FilePersistenceTooBigForSerializationException {
- createFilePersistence();
+ createFilePersistenceForReferencedStaticField();
+ createFilePersistenceForReferencedStaticField();
+ }
+
+ private void createFilePersistenceForReferencedStaticField()
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ builder.setPathName(path.getAbsolutePath());
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(true);
+ final IFilePersistence filePersistence = builder.build();
+ filePersistence
+ .referencedByPesistedStaticField(PersistableWithStaticField.class);
+ final IExclusiveDataAccessSession session = filePersistence
+ .createExclusiveDataAccessSession();
+ session.open();
+ session.close();
+ filePersistence.close();
+ }
+
+ @SuppressWarnings("PMD")
+ public void testStoredStatic() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException {
+ createFilePersistenceForStoredStatic();
// second failed before correction
- createFilePersistence();
+ createFilePersistenceForStoredStatic();
}
- private void createFilePersistence() throws FilePersistenceException,
+ private void createFilePersistenceForStoredStatic()
+ throws FilePersistenceException,
FilePersistenceInvalidClassException,
FilePersistenceNotSerializableException,
FilePersistenceClassNotFoundException,
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob1.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob1.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob1.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -26,6 +26,10 @@
@StoreNotUseStandardSerialization
public class Bob1 implements IBob, Serializable {// NOPMD
+
+ @SuppressWarnings("unused")
+ private static long aStaticFinalLongField = -1L;// NOPMD
+
/**
*
*/
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/manager/TestObjectIOManagerStaticFieldCase.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/manager/TestObjectIOManagerStaticFieldCase.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/manager/TestObjectIOManagerStaticFieldCase.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -80,11 +80,12 @@
writeResult);
assertReferenceChange(objectAndPersistInfo, new Class[] { null },
new Class[] { Integer.class }, writeResult);
- assertType(new int[] { HelperBinaryConversion.INTEGER_TYPE,
+ assertType(new int[] { HelperBinaryConversion.LONG_TYPE,
+ HelperBinaryConversion.INTEGER_TYPE,
HelperBinaryConversion.REFERENCE_TYPE }, writeResult);
assertWriteInformationCleared(objectAndPersistInfo);
- assertOriginalValue(new Object[] { Integer.valueOf(0), fieldValue },
- objectAndPersistInfo);
+ assertOriginalValue(new Object[] { Long.valueOf(-1),
+ Integer.valueOf(0), fieldValue }, objectAndPersistInfo);
/* second write state not change */
writeResult = write(objectAndPersistInfo);
@@ -95,8 +96,8 @@
writeResult);
assertNoReferenceChange(writeResult);
assertWriteInformationCleared(objectAndPersistInfo);
- assertOriginalValue(new Object[] { Integer.valueOf(0), fieldValue },
- objectAndPersistInfo);
+ assertOriginalValue(new Object[] { Long.valueOf(-1),
+ Integer.valueOf(0), fieldValue }, objectAndPersistInfo);
/* third write state change */
fieldValue = Integer.valueOf(1);
@@ -109,11 +110,12 @@
assertReferenceChange(objectAndPersistInfo,
new Class[] { Integer.class }, new Class[] { Integer.class },
writeResult);
- assertType(new int[] { HelperBinaryConversion.INTEGER_TYPE,
+ assertType(new int[] { HelperBinaryConversion.LONG_TYPE,
+ HelperBinaryConversion.INTEGER_TYPE,
HelperBinaryConversion.REFERENCE_TYPE }, writeResult);
assertWriteInformationCleared(objectAndPersistInfo);
- assertOriginalValue(new Object[] { Integer.valueOf(1), fieldValue },
- objectAndPersistInfo);
+ assertOriginalValue(new Object[] { Long.valueOf(-1),
+ Integer.valueOf(1), fieldValue }, objectAndPersistInfo);
/* fourth write state change */
Bob1.setObject(null);
@@ -124,11 +126,12 @@
assertReferenceChange(objectAndPersistInfo,
new Class[] { Integer.class }, new Class[] { null },
writeResult);
- assertType(new int[] { HelperBinaryConversion.INTEGER_TYPE,
+ assertType(new int[] { HelperBinaryConversion.LONG_TYPE,
+ HelperBinaryConversion.INTEGER_TYPE,
HelperBinaryConversion.REFERENCE_TYPE }, writeResult);
assertWriteInformationCleared(objectAndPersistInfo);
- assertOriginalValue(new Object[] { Integer.valueOf(1), null },
- objectAndPersistInfo);
+ assertOriginalValue(new Object[] { Long.valueOf(-1),
+ Integer.valueOf(1), null }, objectAndPersistInfo);
/* fifth write state change */
fieldValue = Integer.valueOf(3);
@@ -141,11 +144,12 @@
writeResult);
assertReferenceChange(objectAndPersistInfo, new Class[] { null },
new Class[] { Integer.class }, writeResult);
- assertType(new int[] { HelperBinaryConversion.INTEGER_TYPE,
+ assertType(new int[] { HelperBinaryConversion.LONG_TYPE,
+ HelperBinaryConversion.INTEGER_TYPE,
HelperBinaryConversion.REFERENCE_TYPE }, writeResult);
assertWriteInformationCleared(objectAndPersistInfo);
- assertOriginalValue(new Object[] { Integer.valueOf(2), fieldValue },
- objectAndPersistInfo);
+ assertOriginalValue(new Object[] { Long.valueOf(-1),
+ Integer.valueOf(2), fieldValue }, objectAndPersistInfo);
/**/
writeSon(writeResult);
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/ObjectIOStaticTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/ObjectIOStaticTest.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/ObjectIOStaticTest.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -55,6 +55,7 @@
classInfoFactory, proxyManager2, helperBinaryConversion);
final ClassInfo classInfo = classInfoFactory
.getNoProxyClassInfo(Bob1.class);
+ // 10 as static field value to save
Bob1.setStaticValue(10);
final ObjectAndPersistInfo objectAndPersistInfo =
/**/new ObjectAndPersistInfo(classInfo);
@@ -69,7 +70,9 @@
*/, objectAndPersistInfo, false/* updateOriginalValue */);
final ObjectInputStatic objectInput = new ObjectInputStatic(this,
classInfoFactory, proxyManager2, helperBinaryConversion);
+ // change static field value to 0
Bob1.setStaticValue(0);
+ // read static field value and check it is 10
objectInput.setObjectStaticState(objectAndPersistInfo, binary, offset);
assertEquals("bad value", 10, Bob1.getStaticValue());
}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2011-10-02 08:34:45 UTC (rev 2914)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2011-10-03 03:24:41 UTC (rev 2915)
@@ -240,7 +240,7 @@
dataRecordIdentifier);
} else {
created = false;
- // FIXMELUC __________________data not change case
+ // FIXMELUC _____________data not change case
if (data.length != heapRecord.getDataAssociatedSize()) {
deleteDataRecord(dataRecordIdentifier);
heapRecord = createHeapRecordForData(data.length,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-03 03:24:48
|
Revision: 2915
http://joafip.svn.sourceforge.net/joafip/?rev=2915&view=rev
Author: luc_peuvrier
Date: 2011-10-03 03:24:41 +0000 (Mon, 03 Oct 2011)
Log Message:
-----------
after check for static field persistence
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java
trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/AbstractExporter.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectfortest/Bob1.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/manager/TestObjectIOManagerStaticFieldCase.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/ObjectIOStaticTest.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-02 08:34:51
|
Revision: 2914
http://joafip.svn.sourceforge.net/joafip/?rev=2914&view=rev
Author: luc_peuvrier
Date: 2011-10-02 08:34:45 +0000 (Sun, 02 Oct 2011)
Log Message:
-----------
problems with static field modified when persisted
Modified Paths:
--------------
trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-02 08:34:51
|
Revision: 2914
http://joafip.svn.sourceforge.net/joafip/?rev=2914&view=rev
Author: luc_peuvrier
Date: 2011-10-02 08:34:45 +0000 (Sun, 02 Oct 2011)
Log Message:
-----------
problems with static field modified when persisted
Modified Paths:
--------------
trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java 2011-10-02 08:34:03 UTC (rev 2913)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java 2011-10-02 08:34:45 UTC (rev 2914)
@@ -16,6 +16,7 @@
suite.addTestSuite(TestInstanceFactoryUsage.class);
suite.addTestSuite(TestRuntime310Garbage.class);
suite.addTestSuite(TestAutoSave.class);
+ suite.addTestSuite(TestAutoSaveWithStatic.class);
suite.addTestSuite(TestStoredImmutableEnum.class);
suite.addTestSuite(TestFileManagementOptions.class);
// $JUnit-END$
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-02 08:34:09
|
Revision: 2913
http://joafip.svn.sourceforge.net/joafip/?rev=2913&view=rev
Author: luc_peuvrier
Date: 2011-10-02 08:34:03 +0000 (Sun, 02 Oct 2011)
Log Message:
-----------
problems with static field modified when persisted
Modified Paths:
--------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-02 08:34:09
|
Revision: 2913
http://joafip.svn.sourceforge.net/joafip/?rev=2913&view=rev
Author: luc_peuvrier
Date: 2011-10-02 08:34:03 +0000 (Sun, 02 Oct 2011)
Log Message:
-----------
problems with static field modified when persisted
Modified Paths:
--------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java 2011-10-02 08:33:34 UTC (rev 2912)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java 2011-10-02 08:34:03 UTC (rev 2913)
@@ -196,10 +196,9 @@
count++;
final Iterator<String> iterator = attrQue.descendingIterator();
for (int count = 0; count < 2; count++) {
- System.out.println(iterator.next());
+ iterator.next();
}
final String attrs = iterator.next();
- System.out.println(attrs);
printWriter.print(attrs);
printWriter.print(", value=");
printWriter.println(value);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-02 08:33:41
|
Revision: 2912
http://joafip.svn.sourceforge.net/joafip/?rev=2912&view=rev
Author: luc_peuvrier
Date: 2011-10-02 08:33:34 +0000 (Sun, 02 Oct 2011)
Log Message:
-----------
problems with static field modified when persisted
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java
Added Paths:
-----------
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticFieldMap.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java 2011-10-01 17:08:48 UTC (rev 2911)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -42,6 +42,8 @@
public StoreSynchro() { // NOPMD
super();
+ // FIXMELUC _____________________for test
+ Thread.dumpStack();
}
public void setPersistenceId(final int persistenceId) {
@@ -60,7 +62,6 @@
/* a not valid identifier value when access session is closed */
fileAccessSessionIdentifier = -1;
}
-
return persistenceId | fileAccessSessionIdentifier;
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-10-01 17:08:48 UTC (rev 2911)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -425,8 +425,9 @@
queueSize = 0;
queueNumberOfWeakRef = 0;
}
- // static persistence information live with file persistence
- // staticStateMap.clear();
+ // FIXMELUC ____________________static persistence information live
+ // with file persistence
+ staticStateMap.clear();
// checkNullFieldError();
}
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java 2011-10-01 17:08:48 UTC (rev 2911)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -1248,8 +1248,8 @@
objectAndPersistInfo
.setDataRecordIdentifier(dataRecordIdentifier);
objectAndPersistInfo.setReplacementDefList(replacementDef);
- objectInputStatic.setObjectState(objectAndPersistInfo, binary,
- offset);
+ objectInputStatic.setObjectStaticState(objectAndPersistInfo,
+ binary, offset);
// not a new object to add to storage, created reading in
// storage
objectAndPersistInfo.setNewObject(false);
Added: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.service.rel400;
+
+import java.util.Map;
+
+import net.sf.joafip.StorableClass;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@StorableClass
+public class PersistableWithStaticField {
+
+ private static final PersistableWithStaticField EMPTY = new PersistableWithStaticField(
+ "");
+
+ private static Map<String, PersistableWithStaticField> map;
+
+ static {
+ map = new PersistableWithStaticFieldMap();
+ map.put(EMPTY.getKey(), EMPTY);
+ }
+
+ private final String key;
+
+ public PersistableWithStaticField(final String key) {
+ super();
+ this.key = key;
+ }
+
+ public String getKey() {
+ return key;
+ }
+}
Added: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticFieldMap.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticFieldMap.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticFieldMap.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.service.rel400;
+
+import net.sf.joafip.StorableClass;
+import net.sf.joafip.StoreNotUseStandardSerialization;
+import net.sf.joafip.java.util.PTreeMap;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@StoreNotUseStandardSerialization
+@StorableClass
+public class PersistableWithStaticFieldMap extends
+ PTreeMap<String, PersistableWithStaticField> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4317793725458311008L;
+
+}
Added: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.service.rel400;
+
+import net.sf.joafip.AbstractDeleteFileTestCase;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.TestException;
+import net.sf.joafip.service.FilePersistenceBuilder;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IExclusiveDataAccessSession;
+import net.sf.joafip.service.IFilePersistence;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@StorableAccess
+public class TestAutoSaveWithStatic extends AbstractDeleteFileTestCase {
+
+ public TestAutoSaveWithStatic() throws TestException {
+ super();
+ }
+
+ public TestAutoSaveWithStatic(final String name) throws TestException {
+ super(name);
+ }
+
+ @SuppressWarnings("PMD")
+ public void test() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException {
+ createFilePersistence();
+ // second failed before correction
+ createFilePersistence();
+ }
+
+ private void createFilePersistence() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ builder.setPathName(path.getAbsolutePath());
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(true);
+ final IFilePersistence filePersistence = builder.build();
+ filePersistence.storedStaticField(PersistableWithStaticField.class);
+ final IExclusiveDataAccessSession session = filePersistence
+ .createExclusiveDataAccessSession();
+ session.open();
+ session.close();
+ filePersistence.close();
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-02 08:33:41
|
Revision: 2912
http://joafip.svn.sourceforge.net/joafip/?rev=2912&view=rev
Author: luc_peuvrier
Date: 2011-10-02 08:33:34 +0000 (Sun, 02 Oct 2011)
Log Message:
-----------
problems with static field modified when persisted
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java
Added Paths:
-----------
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticFieldMap.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-01 17:08:58
|
Revision: 2911
http://joafip.svn.sourceforge.net/joafip/?rev=2911&view=rev
Author: luc_peuvrier
Date: 2011-10-01 17:08:48 +0000 (Sat, 01 Oct 2011)
Log Message:
-----------
IInstanceFactory field are now transient
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/ExclusiveDataAccessSession.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckJoafipDAO.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Exporter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Garbage.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Inserter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Searcher.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/AbstractPLinkedTreeSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/AbstractPTreeSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/MapCollectionValues.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PHashMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PHashMapKeySet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PHashSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedHashMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedHashSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedMapKeySet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedTreeMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PMapKeyNavigableSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PSynchronizedList.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PTreeMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/arraylist/ArrayListSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/hash/HashSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/hash/HashSupportIterator.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/hash/HashSupportNodeEntry.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linked/hash/LinkedHashSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linked/tree/LinkedTreeSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linkedlist/LinkedListSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/tree/TreeSupport.java
trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/impl/memory/service/RBTNodeManager.java
trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/service/RedBlackTree.java
Added Paths:
-----------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ImportSearcher.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Importer.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterFewInsertAndExport.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportTransform.java
trunk/joafip-4test/src/main/resources/extract.xsl
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/ExclusiveDataAccessSession.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/ExclusiveDataAccessSession.java 2011-10-01 16:45:37 UTC (rev 2910)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/ExclusiveDataAccessSession.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -39,7 +39,8 @@
private static final String SAVE_ERROR = "save error";
- private final IInstanceFactory instanceFactory = new InstanceFactory(this);
+ private final transient IInstanceFactory instanceFactory = new InstanceFactory(
+ this);
public ExclusiveDataAccessSession(final FilePersistence filePersistence) {
super(filePersistence);
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java 2011-10-01 16:45:37 UTC (rev 2910)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -166,7 +166,7 @@
*/
private int zipCompressionLevel = Deflater.BEST_SPEED;
- private IInstanceFactory instanceFactory;
+ private transient IInstanceFactory instanceFactory;
protected final HelperBinaryConversion helperBinaryConversion;
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckJoafipDAO.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckJoafipDAO.java 2011-10-01 16:45:37 UTC (rev 2910)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckJoafipDAO.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -40,7 +40,7 @@
private IDataAccessSession session;
- private IInstanceFactory instanceFactory;
+ private transient IInstanceFactory instanceFactory;
private SpellCheckBase spellCheckBase;
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -0,0 +1,455 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.performance.items.service;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.lang.reflect.Field;
+import java.util.List;
+import java.util.Map;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
+import net.sf.joafip.file.entity.PageNode;
+import net.sf.joafip.file.service.RandomAccessFileReadWriteCache;
+import net.sf.joafip.java.util.PLinkedTreeSet;
+import net.sf.joafip.meminspector.service.MemInspectorException;
+import net.sf.joafip.meminspector.service.inspect.MemInspector;
+import net.sf.joafip.meminspector.service.show.ShowObjectTree;
+import net.sf.joafip.performance.items.entity.Item;
+import net.sf.joafip.performance.items.entity.ItemList;
+import net.sf.joafip.performance.items.entity.ItemTemplate;
+import net.sf.joafip.performance.items.entity.ItemTemplateList;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IDataAccessSession;
+import net.sf.joafip.service.MemInspectorJoafipSetup;
+import net.sf.joafip.store.service.StoreClassNotFoundException;
+import net.sf.joafip.store.service.StoreException;
+import net.sf.joafip.store.service.proxy.StaticProxyCallBack;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@SuppressWarnings("PMD")
+@NotStorableClass
+@StorableAccess
+public class AbstractInserter extends AbstractPerfService {
+
+ private static final File FILE_FOR_LUC = new File(RUNTIME_DIR
+ + "/forLuc.txt");
+
+ public static final File MEM_BIN = new File(RUNTIME_DIR + "/mem.bin");
+
+ private static final File MEM2_BIN = new File(RUNTIME_DIR + "/mem2.bin");
+
+ private static final boolean MEM_INSPECT = false;
+
+ private static final boolean OBJ_MEM_SIZE = false;
+
+ private MemInspector memInspector;
+
+ private boolean markNew;
+
+ private int pageSetSize;
+
+ private int readCacheMapSize;
+
+ private int writeCacheMapSize;
+
+ private int freePageRootNodeSize;
+
+ private int usedPageRootNodeSize;
+
+ public AbstractInserter(final String pathName)
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceTooBigForSerializationException {
+ super(pathName);
+ }
+
+ protected void run(final int numberOfItem) throws FilePersistenceException,
+ StoreException, FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException, MemInspectorException,
+ IOException, SecurityException, IllegalArgumentException,
+ NoSuchFieldException, IllegalAccessException,
+ FilePersistenceTooBigForSerializationException {
+ final Runtime runtime = Runtime.getRuntime();
+ final MemInspector memInspectorForMemory = new MemInspector();
+ addTemplate();
+ long maxMemUse = 0;
+ long maxMemUse2 = 0;
+ pageSetSize = 0;
+ readCacheMapSize = 0;
+ writeCacheMapSize = 0;
+ freePageRootNodeSize = 0;
+ usedPageRootNodeSize = 0;
+ final IDataAccessSession session = filePersistence
+ .createDataAccessSession();
+ initMemInspector();
+ session.open();
+ initializeByItemDuration();
+ boolean added = false;
+ long duration = 0;
+ for (int identifier = 0; !added && identifier < numberOfItem + 1; identifier++) {
+ // final ItemTemplateList itemTemplateList =
+ // getItemTemplateList(session);
+ // final ItemTemplate itemTemplate;
+ // switch (identifier % 3) {
+ // case 0:
+ // itemTemplate = itemTemplateList.getItemTemplate(1);
+ // break;
+ // case 1:
+ // itemTemplate = itemTemplateList.getItemTemplate(2);
+ // break;
+ // case 2:
+ // itemTemplate = itemTemplateList.getItemTemplate(3);
+ // break;
+ // default:
+ // itemTemplate = null;
+ // }
+ addItem(session, identifier);
+
+ if (identifier % BATCH_SIZE == BATCH_SIZE - 1) {
+
+ final long startTime = System.currentTimeMillis();
+ session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
+ final long currentTime = System.currentTimeMillis();
+ System.gc();
+ added = checkAdded(byItemIndex);
+ duration += (currentTime - startTime);
+ final long byItem = duration * 1000 / (identifier + 1);
+ final long memUse = runtime.totalMemory()
+ - runtime.freeMemory();
+ byItemMem[byItemIndex] = (int) (memUse / 1024);
+ if (memUse > maxMemUse) {
+ maxMemUse = memUse;
+ }
+ byItemDuration[byItemIndex] = (int) byItem;
+ final StringBuilder builder = new StringBuilder();
+ builder.append('\n');
+ builder.append(duration);
+ builder.append(" mS ");
+ builder.append(identifier + 1);
+ builder.append(" appened, by item ");
+ builder.append(byItem);
+ builder.append(" µS\nmem used=");
+ builder.append(mem(memUse));
+ builder.append("\nmax= ");
+ builder.append(mem(maxMemUse));
+ if (OBJ_MEM_SIZE) {
+ final long memUse2 = memInspectorForMemory
+ .memoryUsed(filePersistence);
+ if (memUse2 > maxMemUse2) {// NOPMD
+ maxMemUse2 = memUse2;
+ }
+ byItemMem2[byItemIndex] = (int) (memUse2 / 1024);
+ builder.append("\n\nuse= ");
+ builder.append(mem(memUse2));
+ builder.append("\nmax= ");
+ builder.append(mem(maxMemUse2));
+ }
+ if (FILE_CACHE) {
+ builder.append("\npageSet size=");
+ builder.append(pageSetSize);
+ builder.append('/');
+ builder.append(NUMBER_OF_PAGE);
+ builder.append("\nreadCacheMapSize size=");
+ builder.append(readCacheMapSize);
+ builder.append("\nwriteCacheMapSize size=");
+ builder.append(writeCacheMapSize);
+ builder.append("\nfreePageRootNodeSize size=");
+ builder.append(freePageRootNodeSize);
+ builder.append("\nusedPageRootNodeSize size=");
+ builder.append(usedPageRootNodeSize);
+ }
+ builder.append("\nWO SIZE=");
+ builder.append(StaticProxyCallBack.size());
+ logger.info(builder.toString());
+ byItemIndex++;
+
+ session.open();
+ }
+ }
+
+ session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
+
+ session.open();
+ final ItemList itemList = getItemList(session);
+ itemList.removeItem(NUMBER_OF_ITEM);
+ session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
+
+ FILE_FOR_LUC.delete();
+
+ logSize(-1, duration);
+
+ // startTime = System.currentTimeMillis();
+ // final int numberGarbaged = filePersistence.garbageSweep();
+ // endTime = System.currentTimeMillis();
+ // duration = (endTime - startTime);
+ //
+ // logSize(numberGarbaged, duration);
+
+ ObjectOutputStream objectOutputStream = new ObjectOutputStream(
+ new FileOutputStream(DURATION_BIN));
+ objectOutputStream.writeObject(byItemDuration);
+ objectOutputStream.close();
+
+ objectOutputStream = new ObjectOutputStream(new FileOutputStream(
+ MEM_BIN));
+ objectOutputStream.writeObject(byItemMem);
+ objectOutputStream.close();
+
+ if (OBJ_MEM_SIZE) {
+ objectOutputStream = new ObjectOutputStream(new FileOutputStream(
+ MEM2_BIN));
+ objectOutputStream.writeObject(byItemMem2);
+ objectOutputStream.close();
+ }
+
+ if (added) {
+ ShowObjectTree.show("runtime/mem.bin");
+ }
+ }
+
+ protected void close() throws FilePersistenceException {
+ filePersistence.close();
+ }
+
+ private void initMemInspector() throws MemInspectorException {
+ if (MEM_INSPECT) {
+ memInspector = new MemInspector();
+ MemInspectorJoafipSetup.setup(memInspector);
+ // memInspector.inspect(this, false);
+ markNew = false;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private boolean checkAdded(final int byItemIndex)
+ throws MemInspectorException, SecurityException,
+ NoSuchFieldException, IllegalArgumentException,
+ IllegalAccessException {
+ final boolean added;
+ if (MEM_INSPECT) {
+ if (markNew) {
+ memInspector.inspect(this, true);
+ added = memInspector.added();
+ if (added) {
+ memInspector.serialize(new File("runtime/mem.bin"));
+ }
+ } else {
+ memInspector.inspect(this, false);
+ markNew = byItemIndex >= 2;
+ added = false;
+ }
+ if (FILE_CACHE) {
+ final List<Object> list = memInspector
+ .getInstanceOfClass("net.sf.joafip.file.service.RandomAccessFileReadWriteCache");
+ if (list.size() != 1) {
+ throw new MemInspectorException(
+ "bad number of RandomAccessFileReadWriteCache instance: "
+ + list.size());
+ }
+ final Object fileCache = list.get(0);
+ Field field = RandomAccessFileReadWriteCache.class
+ .getDeclaredField("pageSet");
+ field.setAccessible(true);
+ final PLinkedTreeSet<Long> pageSet = (PLinkedTreeSet<Long>) field
+ .get(fileCache);
+ pageSetSize = pageSet.size();
+
+ field = RandomAccessFileReadWriteCache.class
+ .getDeclaredField("readCacheMap");
+ field.setAccessible(true);
+ final Map<Long, PageNode> readCacheMap = (Map<Long, PageNode>) field
+ .get(fileCache);
+ readCacheMapSize = readCacheMap.size();
+
+ field = RandomAccessFileReadWriteCache.class
+ .getDeclaredField("writeCacheMap");
+ field.setAccessible(true);
+ final Map<Long, PageNode> writeCacheMap = (Map<Long, PageNode>) field
+ .get(fileCache);
+ writeCacheMapSize = writeCacheMap.size();
+
+ field = RandomAccessFileReadWriteCache.class
+ .getDeclaredField("freePageRootNode");
+ field.setAccessible(true);
+ PageNode pageNode = (PageNode) field.get(fileCache);
+ freePageRootNodeSize = pageNodeListSize(pageNode);
+
+ field = RandomAccessFileReadWriteCache.class
+ .getDeclaredField("usedPageRootNode");
+ field.setAccessible(true);
+ pageNode = (PageNode) field.get(fileCache);
+ usedPageRootNodeSize = pageNodeListSize(pageNode);
+ }
+ } else {
+ added = false;
+ }
+ return added;
+ }
+
+ /**
+ * @param numberGarbaged
+ * @param duration
+ * @throws FilePersistenceException
+ * @throws FileNotFoundException
+ */
+ private void logSize(final int numberGarbaged, final long duration)
+ throws FilePersistenceException, FileNotFoundException {
+ PrintWriter writer;
+ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(FILE_FOR_LUC, true))));
+ String message;
+ message = "-----------------------";
+ printMessage(writer, message);
+
+ message = "nb of item=" + NUMBER_OF_ITEM;
+ printMessage(writer, message);
+ message = "batch size=" + BATCH_SIZE;
+ printMessage(writer, message);
+ message = "duration=" + duration + " mS";
+ printMessage(writer, message);
+
+ if (numberGarbaged >= 0) {
+ message = "garbaged=" + numberGarbaged;
+ printMessage(writer, message);
+ }
+ if (filePersistence.isGarbageManagement()) {
+ message = "to garbage=" + filePersistence.getNumberOfToGarbage();
+ printMessage(writer, message);
+ message = "garbage candidate="
+ + filePersistence.getNumberOfGarbageCandidate();
+ printMessage(writer, message);
+ }
+ message = "nb of data record="
+ + filePersistence.getNumberOfDataRecord();
+ printMessage(writer, message);
+ message = "nb of free record="
+ + filePersistence.getNumberOfFreeRecord();
+ printMessage(writer, message);
+ message = "used size=" + filePersistence.usedSize();
+ printMessage(writer, message);
+ message = "free size=" + filePersistence.freeSize();
+ printMessage(writer, message);
+ message = "heap size=" + filePersistence.totalSize();
+ printMessage(writer, message);
+ writer.close();
+ }
+
+ private int pageNodeListSize(final PageNode pageNode) {
+ int size = 0;
+ PageNode current = pageNode;
+ while (current != null) {
+ size++;
+ current = current.next;
+ }
+ return size;
+ }
+
+ private String mem(final long value) {
+ final long ktot = value / 1024;
+ final int b = (int) (value % 1024);
+ final int k = (int) (ktot % 1024);
+ final long mtot = ktot / 1024;
+ final long m = mtot % 1024;
+ final long gtot = mtot / 1024;
+ return String.format("%03d g %04d m %04d k %04d b", gtot, m, k, b);
+ }
+
+ /**
+ * @param writer
+ * @param message
+ */
+ private void printMessage(final PrintWriter writer, final String message) {
+ logger.info(message);
+ writer.println(message);
+ }
+
+ /**
+ * @param session
+ * @param identifier
+ * @throws FilePersistenceException
+ */
+ private void addItem(final IDataAccessSession session, final int identifier)
+ throws FilePersistenceException {
+ try {
+ final Item item = new Item(identifier, null/* itemTemplate */,
+ "item" + identifier);
+ final ItemList itemList = getItemList(session);
+ itemList.addItem(item);
+ } catch (final RuntimeException exception) {
+ logger.fatal("adding item " + identifier, exception);
+ throw exception;
+ }
+ }
+
+ private void addTemplate() throws FilePersistenceException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceTooBigForSerializationException {
+ final ItemTemplate itemTemplate1 = new ItemTemplate(1, "template1");
+ final ItemTemplate itemTemplate2 = new ItemTemplate(2, "template2");
+ final ItemTemplate itemTemplate3 = new ItemTemplate(3, "template3");
+ final IDataAccessSession session = filePersistence
+ .createDataAccessSession();
+ session.open();
+ final ItemTemplateList itemTemplateList = getItemTemplateList(session);
+ itemTemplateList.addItemTemplate(itemTemplate1);
+ itemTemplateList.addItemTemplate(itemTemplate2);
+ itemTemplateList.addItemTemplate(itemTemplate3);
+ session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
+ }
+
+ protected void export(final String directoryName)
+ throws FilePersistenceException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceTooBigForSerializationException {
+ filePersistence.xmlExport(directoryName, directoryName + "/tmp", false);
+ }
+}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java 2011-10-01 16:45:37 UTC (rev 2910)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -41,13 +41,13 @@
@StorableAccess
public class AbstractPerfService {
+ protected final JoafipLogger logger = JoafipLogger.getLogger(getClass());// NOPMD
+
protected static final String RUNTIME_DIR = "runtime_perf";
public static final File DURATION_BIN = new File(RUNTIME_DIR
+ "/duration.bin");
- protected final JoafipLogger logger = JoafipLogger.getLogger(getClass());// NOPMD
-
protected static final int BATCH_SIZE = 1000;
protected static final int NUMBER_OF_ITEM = 1000000;
@@ -77,7 +77,8 @@
protected int byItemIndex;
- public AbstractPerfService() throws FilePersistenceException,
+ public AbstractPerfService(final String pathName)
+ throws FilePersistenceException,
FilePersistenceInvalidClassException,
FilePersistenceNotSerializableException,
FilePersistenceClassNotFoundException,
@@ -86,7 +87,7 @@
super();
final FilePersistenceBuilder builder = new FilePersistenceBuilder();
try {
- builder.setPathName(RUNTIME_DIR);
+ builder.setPathName(pathName);
builder.setRemoveFiles(false);
builder.setProxyMode(true);
builder.setCrashSafeMode(CRASH_SAFE_MODE);
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.performance.items.service;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.LinkedList;
+import java.util.List;
+
+import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.performance.items.entity.ItemList;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IDataAccessSession;
+import net.sf.joafip.store.service.StoreClassNotFoundException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class AbstractSearcher extends AbstractPerfService {
+
+ private final JoafipLogger logger = JoafipLogger.getLogger(getClass());
+
+ public AbstractSearcher(final String pathName)
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceTooBigForSerializationException {
+ super(pathName);
+ }
+
+ protected void run() throws FilePersistenceException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException, FileNotFoundException,
+ IOException, FilePersistenceTooBigForSerializationException {
+
+ long maxSearchTime = Long.MIN_VALUE;
+ long minSearchTime = Long.MAX_VALUE;
+ final long startTime = System.currentTimeMillis();
+ final IDataAccessSession session = filePersistence
+ .createDataAccessSession();
+ session.open();
+ initializeByItemDuration();
+ int missingCount = 0;
+ final List<Integer> missingList = new LinkedList<Integer>();
+ for (int identifier = 0; identifier < NUMBER_OF_ITEM; identifier++) {
+ final ItemList itemList = getItemList(session);
+ final long startSearchTime = System.currentTimeMillis();
+ if (itemList.get(identifier) == null) {
+ // throw new
+ // IllegalStateException("missing item for identifier "
+ // + identifier);
+ logger.info("missing item for identifier " + identifier);
+ missingCount++;
+ if (missingCount < 20) {
+ missingList.add(identifier);
+ }
+ }
+ final long currentTime = System.currentTimeMillis();
+ final long searchDuration = currentTime - startSearchTime;
+ if (searchDuration > maxSearchTime) {
+ maxSearchTime = searchDuration;
+ }
+ if (searchDuration < minSearchTime) {
+ minSearchTime = searchDuration;
+ }
+ if (identifier % BATCH_SIZE == BATCH_SIZE - 1) {
+ session.close(EnumFilePersistenceCloseAction.DO_NOT_SAVE);
+ session.open();
+ final long duration = (currentTime - startTime);
+ final long byItem = duration * 1000 / (identifier + 1);
+ byItemDuration[byItemIndex++] = (int) byItem;
+ logger.info(duration + " mS " + (identifier + 1)
+ + " found, by item " + byItem + " uS");
+ }
+ }
+ session.close(EnumFilePersistenceCloseAction.DO_NOT_SAVE);
+ final long endTime = System.currentTimeMillis();
+ logger.info("min search time " + minSearchTime);
+ logger.info("max search time " + maxSearchTime);
+ logger.info((endTime - startTime) + " mS for " + NUMBER_OF_ITEM
+ + " items");
+ logger.info("missing count=" + missingCount);
+ logger.info("missing list=" + missingList.toString());
+ final ObjectOutputStream objectOutputStream = new ObjectOutputStream(
+ new FileOutputStream(DURATION_BIN));
+ objectOutputStream.writeObject(byItemDuration);
+ objectOutputStream.close();
+ }
+}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Exporter.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Exporter.java 2011-10-01 16:45:37 UTC (rev 2910)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Exporter.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -64,12 +64,6 @@
FilePersistenceClassNotFoundException,
FilePersistenceDataCorruptedException,
FilePersistenceTooBigForSerializationException {
- // final FilePersistence filePersistence = new FilePersistence(1, null,
- // "runtime_perf",
- // /**/false/* do not remove files */,
- // /**/1024/* PAGE_SIZE */, 1024/* NUMBER_OF_PAGE */,
- // /**/false/* GARBAGE */,
- // /**/false/* CRASH_SAFE_MODE */);
final FilePersistenceBuilder builder = new FilePersistenceBuilder();
builder.setPathName("runtime_perf");
builder.setFileCache(/**/1024/* PAGE_SIZE */, 1024/* NUMBER_OF_PAGE */);
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Garbage.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Garbage.java 2011-10-01 16:45:37 UTC (rev 2910)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Garbage.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -38,20 +38,20 @@
public static void main(final String[] args) {
Garbage garbage;
try {
- garbage = new Garbage();
+ garbage = new Garbage(RUNTIME_DIR);
garbage.execute();
} catch (final Throwable throwable) {// NOPMD catch all
LOGGER.fatal("error", throwable);
}
}
- public Garbage() throws FilePersistenceException,
+ public Garbage(final String pathName) throws FilePersistenceException,
FilePersistenceInvalidClassException,
FilePersistenceNotSerializableException,
FilePersistenceClassNotFoundException,
FilePersistenceDataCorruptedException, StoreClassNotFoundException,
FilePersistenceTooBigForSerializationException {
- super();
+ super(pathName);
}
private long displayTime;
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ImportSearcher.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ImportSearcher.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ImportSearcher.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2007 Luc Peuvrier
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.performance.items.service;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.store.service.StoreClassNotFoundException;
+
+@NotStorableClass
+@StorableAccess
+public class ImportSearcher extends AbstractSearcher {
+
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(ImportSearcher.class);
+
+ public ImportSearcher(final String pathName)
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceTooBigForSerializationException {
+ super(pathName);
+ }
+
+ public static void main(final String[] args) {
+ ImportSearcher searcher;
+ try {
+ searcher = new ImportSearcher("runtime_perf/from_import");
+ searcher.run();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Importer.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Importer.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Importer.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.performance.items.service;
+
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.service.FilePersistenceBuilder;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IFilePersistence;
+import net.sf.joafip.store.service.export_import.in.IImportListener;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public final class Importer implements IImportListener {
+
+ private final static JoafipLogger LOGGER = JoafipLogger
+ .getLogger(Importer.class);
+
+ private long startTime;
+
+ private long numberOfImported;// NOPMD
+
+ public static void main(final String[] args) {
+ try {
+ final Importer exporter = new Importer();
+ exporter.run();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+
+ private Importer() {
+ super();
+ }
+
+ private void run() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ builder.setPathName("runtime_perf/from_import");
+ builder.setFileCache(/**/1024/* PAGE_SIZE */, 1024/* NUMBER_OF_PAGE */);
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(false);
+ builder.setGarbageManagement(false);
+ builder.setCrashSafeMode(false);
+ builder.setRemoveFiles(true);
+ final IFilePersistence filePersistence = builder.build();
+
+ filePersistence.setImportListener(this);
+ startTime = System.currentTimeMillis();
+ filePersistence.xmlImport("runtime_perf/export");
+ System.out.println(numberOfImported + " imported, duration "// NOPMD
+ + (System.currentTimeMillis() - startTime));
+ filePersistence.close();
+ }
+
+ @Override
+ public void numberOfImported(final long numberOfImported) {
+ this.numberOfImported = numberOfImported;
+ if (numberOfImported % 100 == 0) {
+ final double byRecordDuration = (double) (System
+ .currentTimeMillis() - startTime)
+ / (double) numberOfImported;
+ System.out.println("imported " + numberOfImported// NOPMD
+ + " bye record duration " + byRecordDuration + " mS");
+ }
+ }
+}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Inserter.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Inserter.java 2011-10-01 16:45:37 UTC (rev 2910)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Inserter.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Luc Peuvrier
+ * Copyright 2011 Luc Peuvrier
*
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
* Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
@@ -16,84 +16,34 @@
*/
package net.sf.joafip.performance.items.service;//NOPMD
-import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.lang.reflect.Field;
-import java.util.List;
-import java.util.Map;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
-import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
-import net.sf.joafip.file.entity.PageNode;
-import net.sf.joafip.file.service.RandomAccessFileReadWriteCache;
-import net.sf.joafip.java.util.PLinkedTreeSet;
import net.sf.joafip.logger.JoafipLogger;
-import net.sf.joafip.meminspector.service.MemInspectorException;
-import net.sf.joafip.meminspector.service.inspect.MemInspector;
-import net.sf.joafip.meminspector.service.show.ShowObjectTree;
-import net.sf.joafip.performance.items.entity.Item;
-import net.sf.joafip.performance.items.entity.ItemList;
-import net.sf.joafip.performance.items.entity.ItemTemplate;
-import net.sf.joafip.performance.items.entity.ItemTemplateList;
import net.sf.joafip.service.FilePersistenceClassNotFoundException;
import net.sf.joafip.service.FilePersistenceDataCorruptedException;
import net.sf.joafip.service.FilePersistenceException;
import net.sf.joafip.service.FilePersistenceInvalidClassException;
import net.sf.joafip.service.FilePersistenceNotSerializableException;
import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
-import net.sf.joafip.service.IDataAccessSession;
-import net.sf.joafip.service.MemInspectorJoafipSetup;
import net.sf.joafip.store.service.StoreClassNotFoundException;
-import net.sf.joafip.store.service.StoreException;
-import net.sf.joafip.store.service.proxy.StaticProxyCallBack;
@SuppressWarnings("PMD")
@NotStorableClass
@StorableAccess
-public class Inserter extends AbstractPerfService {
+public class Inserter extends AbstractInserter {
private static final JoafipLogger LOGGER = JoafipLogger
.getLogger(Inserter.class);
- private static final File FILE_FOR_LUC = new File(RUNTIME_DIR
- + "/forLuc.txt");
-
- public static final File MEM_BIN = new File(RUNTIME_DIR + "/mem.bin");
-
- private static final File MEM2_BIN = new File(RUNTIME_DIR + "/mem2.bin");
-
- private static final boolean MEM_INSPECT = false;
-
- private static final boolean OBJ_MEM_SIZE = false;
-
- private MemInspector memInspector;
-
- private boolean markNew;
-
- private int pageSetSize;
-
- private int readCacheMapSize;
-
- private int writeCacheMapSize;
-
- private int freePageRootNodeSize;
-
- private int usedPageRootNodeSize;
-
- public Inserter() throws FilePersistenceException,
+ public Inserter(final String pathName) throws FilePersistenceException,
FilePersistenceInvalidClassException,
FilePersistenceNotSerializableException,
FilePersistenceClassNotFoundException,
FilePersistenceDataCorruptedException, StoreClassNotFoundException,
FilePersistenceTooBigForSerializationException {
- super();
+ super(pathName);
}
public static void main(final String[] args) {
@@ -105,347 +55,11 @@
dataDirectory.mkdirs();
Inserter inserter;
try {
- inserter = new Inserter();
- inserter.run();
+ inserter = new Inserter(RUNTIME_DIR);
+ inserter.run(NUMBER_OF_ITEM);
+ inserter.close();
} catch (final Throwable throwable) {// NOPMD catch all
LOGGER.fatal("error", throwable);
}
}
-
- private void run() throws FilePersistenceException, StoreException,
- FilePersistenceClassNotFoundException,
- FilePersistenceInvalidClassException,
- FilePersistenceDataCorruptedException,
- FilePersistenceNotSerializableException, MemInspectorException,
- IOException, SecurityException, IllegalArgumentException,
- NoSuchFieldException, IllegalAccessException,
- FilePersistenceTooBigForSerializationException {
- final Runtime runtime = Runtime.getRuntime();
- final MemInspector memInspectorForMemory = new MemInspector();
- addTemplate();
- long maxMemUse = 0;
- long maxMemUse2 = 0;
- pageSetSize = 0;
- readCacheMapSize = 0;
- writeCacheMapSize = 0;
- freePageRootNodeSize = 0;
- usedPageRootNodeSize = 0;
- final IDataAccessSession session = filePersistence
- .createDataAccessSession();
- initMemInspector();
- session.open();
- initializeByItemDuration();
- boolean added = false;
- long duration = 0;
- for (int identifier = 0; !added && identifier < NUMBER_OF_ITEM + 1; identifier++) {
- // final ItemTemplateList itemTemplateList =
- // getItemTemplateList(session);
- // final ItemTemplate itemTemplate;
- // switch (identifier % 3) {
- // case 0:
- // itemTemplate = itemTemplateList.getItemTemplate(1);
- // break;
- // case 1:
- // itemTemplate = itemTemplateList.getItemTemplate(2);
- // break;
- // case 2:
- // itemTemplate = itemTemplateList.getItemTemplate(3);
- // break;
- // default:
- // itemTemplate = null;
- // }
- addItem(session, identifier);
-
- if (identifier % BATCH_SIZE == BATCH_SIZE - 1) {
-
- final long startTime = System.currentTimeMillis();
- session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
- final long currentTime = System.currentTimeMillis();
- System.gc();
- added = checkAdded(byItemIndex);
- duration += (currentTime - startTime);
- final long byItem = duration * 1000 / (identifier + 1);
- final long memUse = runtime.totalMemory()
- - runtime.freeMemory();
- byItemMem[byItemIndex] = (int) (memUse / 1024);
- if (memUse > maxMemUse) {
- maxMemUse = memUse;
- }
- byItemDuration[byItemIndex] = (int) byItem;
- final StringBuilder builder = new StringBuilder();
- builder.append('\n');
- builder.append(duration);
- builder.append(" mS ");
- builder.append(identifier + 1);
- builder.append(" appened, by item ");
- builder.append(byItem);
- builder.append(" µS\nmem used=");
- builder.append(mem(memUse));
- builder.append("\nmax= ");
- builder.append(mem(maxMemUse));
- if (OBJ_MEM_SIZE) {
- final long memUse2 = memInspectorForMemory
- .memoryUsed(filePersistence);
- if (memUse2 > maxMemUse2) {// NOPMD
- maxMemUse2 = memUse2;
- }
- byItemMem2[byItemIndex] = (int) (memUse2 / 1024);
- builder.append("\n\nuse= ");
- builder.append(mem(memUse2));
- builder.append("\nmax= ");
- builder.append(mem(maxMemUse2));
- }
- if (FILE_CACHE) {
- builder.append("\npageSet size=");
- builder.append(pageSetSize);
- builder.append('/');
- builder.append(NUMBER_OF_PAGE);
- builder.append("\nreadCacheMapSize size=");
- builder.append(readCacheMapSize);
- builder.append("\nwriteCacheMapSize size=");
- builder.append(writeCacheMapSize);
- builder.append("\nfreePageRootNodeSize size=");
- builder.append(freePageRootNodeSize);
- builder.append("\nusedPageRootNodeSize size=");
- builder.append(usedPageRootNodeSize);
- }
- builder.append("\nWO SIZE=");
- builder.append(StaticProxyCallBack.size());
- LOGGER.info(builder.toString());
- byItemIndex++;
-
- session.open();
- }
- }
-
- session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
-
- session.open();
- final ItemList itemList = getItemList(session);
- itemList.removeItem(NUMBER_OF_ITEM);
- session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
-
- FILE_FOR_LUC.delete();
-
- logSize(-1, duration);
-
- // startTime = System.currentTimeMillis();
- // final int numberGarbaged = filePersistence.garbageSweep();
- // endTime = System.currentTimeMillis();
- // duration = (endTime - startTime);
- //
- // logSize(numberGarbaged, duration);
-
- filePersistence.close();
-
- ObjectOutputStream objectOutputStream = new ObjectOutputStream(
- new FileOutputStream(DURATION_BIN));
- objectOutputStream.writeObject(byItemDuration);
- objectOutputStream.close();
-
- objectOutputStream = new ObjectOutputStream(new FileOutputStream(
- MEM_BIN));
- objectOutputStream.writeObject(byItemMem);
- objectOutputStream.close();
-
- if (OBJ_MEM_SIZE) {
- objectOutputStream = new ObjectOutputStream(new FileOutputStream(
- MEM2_BIN));
- objectOutputStream.writeObject(byItemMem2);
- objectOutputStream.close();
- }
-
- if (added) {
- ShowObjectTree.show("runtime/mem.bin");
- }
- }
-
- private void initMemInspector() throws MemInspectorException {
- if (MEM_INSPECT) {
- memInspector = new MemInspector();
- MemInspectorJoafipSetup.setup(memInspector);
- // memInspector.inspect(this, false);
- markNew = false;
- }
- }
-
- @SuppressWarnings("unchecked")
- private boolean checkAdded(final int byItemIndex)
- throws MemInspectorException, SecurityException,
- NoSuchFieldException, IllegalArgumentException,
- IllegalAccessException {
- final boolean added;
- if (MEM_INSPECT) {
- if (markNew) {
- memInspector.inspect(this, true);
- added = memInspector.added();
- if (added) {
- memInspector.serialize(new File("runtime/mem.bin"));
- }
- } else {
- memInspector.inspect(this, false);
- markNew = byItemIndex >= 2;
- added = false;
- }
- if (FILE_CACHE) {
- final List<Object> list = memInspector
- .getInstanceOfClass("net.sf.joafip.file.service.RandomAccessFileReadWriteCache");
- if (list.size() != 1) {
- throw new MemInspectorException(
- "bad number of RandomAccessFileReadWriteCache instance: "
- + list.size());
- }
- final Object fileCache = list.get(0);
- Field field = RandomAccessFileReadWriteCache.class
- .getDeclaredField("pageSet");
- field.setAccessible(true);
- final PLinkedTreeSet<Long> pageSet = (PLinkedTreeSet<Long>) field
- .get(fileCache);
- pageSetSize = pageSet.size();
-
- field = RandomAccessFileReadWriteCache.class
- .getDeclaredField("readCacheMap");
- field.setAccessible(true);
- final Map<Long, PageNode> readCacheMap = (Map<Long, PageNode>) field
- .get(fileCache);
- readCacheMapSize = readCacheMap.size();
-
- field = RandomAccessFileReadWriteCache.class
- .getDeclaredField("writeCacheMap");
- field.setAccessible(true);
- final Map<Long, PageNode> writeCacheMap = (Map<Long, PageNode>) field
- .get(fileCache);
- writeCacheMapSize = writeCacheMap.size();
-
- field = RandomAccessFileReadWriteCache.class
- .getDeclaredField("freePageRootNode");
- field.setAccessible(true);
- PageNode pageNode = (PageNode) field.get(fileCache);
- freePageRootNodeSize = pageNodeListSize(pageNode);
-
- field = RandomAccessFileReadWriteCache.class
- .getDeclaredField("usedPageRootNode");
- field.setAccessible(true);
- pageNode = (PageNode) field.get(fileCache);
- usedPageRootNodeSize = pageNodeListSize(pageNode);
- }
- } else {
- added = false;
- }
- return added;
- }
-
- private int pageNodeListSize(final PageNode pageNode) {
- int size = 0;
- PageNode current = pageNode;
- while (current != null) {
- size++;
- current = current.next;
- }
- return size;
- }
-
- private String mem(final long value) {
- final long ktot = value / 1024;
- final int b = (int) (value % 1024);
- final int k = (int) (ktot % 1024);
- final long mtot = ktot / 1024;
- final long m = mtot % 1024;
- final long gtot = mtot / 1024;
- return String.format("%03d g %04d m %04d k %04d b", gtot, m, k, b);
- }
-
- /**
- * @param numberGarbaged
- * @param duration
- * @throws FilePersistenceException
- * @throws FileNotFoundException
- */
- private void logSize(final int numberGarbaged, final long duration)
- throws FilePersistenceException, FileNotFoundException {
- PrintWriter writer;
- writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(FILE_FOR_LUC, true))));
- String message;
- message = "-----------------------";
- printMessage(writer, message);
-
- message = "nb of item=" + NUMBER_OF_ITEM;
- printMessage(writer, message);
- message = "batch size=" + BATCH_SIZE;
- printMessage(writer, message);
- message = "duration=" + duration + " mS";
- printMessage(writer, message);
-
- if (numberGarbaged >= 0) {
- message = "garbaged=" + numberGarbaged;
- printMessage(writer, message);
- }
- if (filePersistence.isGarbageManagement()) {
- message = "to garbage=" + filePersistence.getNumberOfToGarbage();
- printMessage(writer, message);
- message = "garbage candidate="
- + filePersistence.getNumberOfGarbageCandidate();
- printMessage(writer, message);
- }
- message = "nb of data record="
- + filePersistence.getNumberOfDataRecord();
- printMessage(writer, message);
- message = "nb of free record="
- + filePersistence.getNumberOfFreeRecord();
- printMessage(writer, message);
- message = "used size=" + filePersistence.usedSize();
- printMessage(writer, message);
- message = "free size=" + filePersistence.freeSize();
- printMessage(writer, message);
- message = "heap size=" + filePersistence.totalSize();
- printMessage(writer, message);
- writer.close();
- }
-
- /**
- * @param writer
- * @param message
- */
- private void printMessage(final PrintWriter writer, final String message) {
- LOGGER.info(message);
- writer.println(message);
- }
-
- /**
- * @param session
- * @param identifier
- * @throws FilePersistenceException
- */
- private void addItem(final IDataAccessSession session, final int identifier)
- throws FilePersistenceException {
- try {
- final Item item = new Item(identifier, null/* itemTemplate */,
- "item" + identifier);
- final ItemList itemList = getItemList(session);
- itemList.addItem(item);
- } catch (final RuntimeException exception) {
- LOGGER.fatal("adding item " + identifier, exception);
- throw exception;
- }
- }
-
- private void addTemplate() throws FilePersistenceException,
- FilePersistenceClassNotFoundException,
- FilePersistenceInvalidClassException,
- FilePersistenceDataCorruptedException,
- FilePersistenceNotSerializableException,
- FilePersistenceTooBigForSerializationException {
- final ItemTemplate itemTemplate1 = new ItemTemplate(1, "template1");
- final ItemTemplate itemTemplate2 = new ItemTemplate(2, "template2");
- final ItemTemplate itemTemplate3 = new ItemTemplate(3, "template3");
- final IDataAccessSession session = filePersistence
- .createDataAccessSession();
- session.open();
- final ItemTemplateList itemTemplateList = getItemTemplateList(session);
- itemTemplateList.addItemTemplate(itemTemplate1);
- itemTemplateList.addItemTemplate(itemTemplate2);
- itemTemplateList.addItemTemplate(itemTemplate3);
- session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
- }
}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterFewInsertAndExport.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterFewInsertAndExport.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterFewInsertAndExport.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.performance.items.service;//NOPMD
+
+import java.io.File;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.store.service.StoreClassNotFoundException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@SuppressWarnings("PMD")
+@NotStorableClass
+@StorableAccess
+public class InserterFewInsertAndExport extends AbstractInserter {
+
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(InserterFewInsertAndExport.class);
+
+ public InserterFewInsertAndExport(final String pathName)
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceTooBigForSerializationException {
+ super(pathName);
+ }
+
+ public static void main(final String[] args) {
+ /* remove existing data */
+ final File dataDirectory = new File("runtime");
+ for (final File file : dataDirectory.listFiles()) {
+ file.delete();
+ }
+ dataDirectory.mkdirs();
+ InserterFewInsertAndExport inserter;
+ try {
+ inserter = new InserterFewInsertAndExport("runtime");
+ inserter.run(1);
+ inserter.export("runtime");
+ inserter.close();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java 2011-10-01 17:08:48 UTC (rev 2911)
@@ -0,0 +1,241 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.performance.items.service;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.logger.JoafipLogger;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public final class MainExportScanner implements ErrorHandler, ContentHandler {
+
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(MainExportScanner.class);
+
+ private final Deque<String> que = new LinkedList<String>();
+
+ private final Deque<String> attrQue = new LinkedList<String>();
+
+ private final Set<Integer> valueSet = new TreeSet<Integer>();
+
+ private int total;
+
+ private int count;
+
+ private PrintWriter printWriter;
+
+ private MainExportScanner() {
+ super();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ final MainExportScanner main = new MainExportScanner();
+ main.run();
+ } catch (Exception exception) {
+ LOGGER.error("execution failure", exception);
+ }
+ }
+
+ private void run() throws ParserConfigurationException, SAXException,
+ IOException {
+ printWriter = new PrintWriter(new File(
+ "runtime_perf/export/missing.txt"));
+ total = 0;
+ count = 0;
+ valueSet.add(108738);
+ valueSet.add(118200);
+ valueSet.add(132948);
+ valueSet.add(142808);
+ valueSet.add(165872);
+
+ final SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+ final SAXParser parser = factory.newSAXParser();
+ final XMLReader reader = parser.getXMLReader();
+ reader.setErrorHandler(this);
+ reader.setContentHandler(this);
+ reader.parse(new InputSource("runtime_perf/export/export.xml"));
+ System.out.println("count=" + count + " total=" + total);// NOPMD
+ printWriter.close();
+ }
+
+ @Override
+ public void warning(final SAXParseException exception) throws SAXException {
+ LOGGER.warn("sax error", exception);
+ }
+
+ @Override
+ public void error(final SAXParseException exception) throws SAXException {
+ LOGGER.warn("sax error", exception);
+ }
+
+ @Override
+ public void fatalError(final SAXParseException exception)
+ throws SAXException {
+ LOGGER.warn("sax error", exception);
+ }...
[truncated message content] |
|
From: <luc...@us...> - 2011-10-01 17:08:55
|
Revision: 2911
http://joafip.svn.sourceforge.net/joafip/?rev=2911&view=rev
Author: luc_peuvrier
Date: 2011-10-01 17:08:48 +0000 (Sat, 01 Oct 2011)
Log Message:
-----------
IInstanceFactory field are now transient
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/ExclusiveDataAccessSession.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckJoafipDAO.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Exporter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Garbage.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Inserter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Searcher.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/AbstractPLinkedTreeSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/AbstractPTreeSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/MapCollectionValues.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PHashMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PHashMapKeySet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PHashSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedHashMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedHashSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedMapKeySet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PLinkedTreeMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PMapKeyNavigableSet.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PSynchronizedList.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PTreeMap.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/arraylist/ArrayListSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/hash/HashSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/hash/HashSupportIterator.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/hash/HashSupportNodeEntry.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linked/hash/LinkedHashSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linked/tree/LinkedTreeSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/linkedlist/LinkedListSupport.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/support/tree/TreeSupport.java
trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/impl/memory/service/RBTNodeManager.java
trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/service/RedBlackTree.java
Added Paths:
-----------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ImportSearcher.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Importer.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterFewInsertAndExport.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportTransform.java
trunk/joafip-4test/src/main/resources/extract.xsl
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-01 16:45:44
|
Revision: 2910
http://joafip.svn.sourceforge.net/joafip/?rev=2910&view=rev
Author: luc_peuvrier
Date: 2011-10-01 16:45:37 +0000 (Sat, 01 Oct 2011)
Log Message:
-----------
correction to access to protected constructor
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java
trunk/joafip/src/main/java/net/sf/joafip/service/AbstractDataAccessSession.java
trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/service/IDataAccessSessionCommon.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImportListener.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java 2011-09-30 01:09:49 UTC (rev 2909)
+++ trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java 2011-10-01 16:45:37 UTC (rev 2910)
@@ -463,7 +463,7 @@
throws ReflectException {
try {
final Constructor<?> constructor = objectClass
- .getConstructor(EMPTY_PARAMETER_TYPES);
+ .getDeclaredConstructor(EMPTY_PARAMETER_TYPES);
constructor.setAccessible(true);
return constructor.newInstance();
} catch (InstantiationException exception) {
@@ -522,7 +522,7 @@
try {
final Constructor<?> constructor = objectClass
- .getConstructor(parameterTypes);
+ .getDeclaredConstructor(parameterTypes);
constructor.setAccessible(true);
return constructor.newInstance(initargs);
} catch (IllegalArgumentException exception) {
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/AbstractDataAccessSession.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/AbstractDataAccessSession.java 2011-09-30 01:09:49 UTC (rev 2909)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/AbstractDataAccessSession.java 2011-10-01 16:45:37 UTC (rev 2910)
@@ -216,6 +216,7 @@
return previousObject;
}
+ @Override
public Object removeObject(final String key)
throws FilePersistenceException {
final Object previousObject;
@@ -233,6 +234,20 @@
}
@Override
+ public void removeAllObject() throws FilePersistenceException {
+ synchronized (mutex) {
+ try {
+ assertPersistenceOpenned();
+ assertOpened();
+ filePersistence.removeAllObject();
+ } catch (FilePersistenceException exception) {
+ logger.error("remove all object error", exception);
+ throw exception;
+ }
+ }
+ }
+
+ @Override
public Set<String> objectKeySet() throws FilePersistenceException {
final Set<String> objectKeySet;
synchronized (mutex) {
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2011-09-30 01:09:49 UTC (rev 2909)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2011-10-01 16:45:37 UTC (rev 2910)
@@ -1423,7 +1423,21 @@
}
/**
+ * remove all persistent object
*
+ * @throws FilePersistenceException
+ */
+ @SuppressWarnings("PMD")
+ @StorableAccess
+ void removeAllObject() throws FilePersistenceException {
+ synchronized (mutex) {
+ assertRootObjectMapDefined();
+ rootObjectMap.clear();
+ }
+ }
+
+ /**
+ *
* @return key set of persistent objects
* @throws FilePersistenceException
*/
@@ -1760,7 +1774,7 @@
public void setImportListener(final IImportListener listener) {
store.setImportListener(listener);
}
-
+
/**
* assert there is no object stored
*
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/IDataAccessSessionCommon.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/IDataAccessSessionCommon.java 2011-09-30 01:09:49 UTC (rev 2909)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/IDataAccessSessionCommon.java 2011-10-01 16:45:37 UTC (rev 2910)
@@ -129,6 +129,13 @@
Object removeObject(final String key) throws FilePersistenceException;
/**
+ * remove all persistent object<br>
+ *
+ * @throws FilePersistenceException
+ */
+ void removeAllObject() throws FilePersistenceException;
+
+ /**
* set enum state from file
*
* @param enumObject
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2011-09-30 01:09:49 UTC (rev 2909)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2011-10-01 16:45:37 UTC (rev 2910)
@@ -667,7 +667,7 @@
throws FilePersistenceException;
void setImportListener(IImportListener listener);
-
+
/**
* declare persisted mutable enum by its class<br>
* (PROPS) can be set using properties file see
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2011-09-30 01:09:49 UTC (rev 2909)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2011-10-01 16:45:37 UTC (rev 2910)
@@ -670,7 +670,7 @@
StoreDataCorruptedException, StoreNotSerializableException;
void setImportListener(IImportListener listener);
-
+
Object newProxyInstance(Object object) throws StoreException;
Object newProxyInstance(Class<?> objectClass, Class<?>[] parameterTypes,
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java 2011-09-30 01:09:49 UTC (rev 2909)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java 2011-10-01 16:45:37 UTC (rev 2910)
@@ -126,7 +126,7 @@
private long numberOfImported;
private IImportListener listener;
-
+
public AbstractImporter(final IStore store) throws ImportException {
super();
try {
@@ -161,7 +161,7 @@
public void doImport(final String directoryName) throws ImportException,
ImportClassNotFoundException, ImportDataCorruptedException,
ImportInvalidClassException, ImportNotSerializableException {
- numberOfImported=0;
+ numberOfImported = 0;
final File directory = new File(directoryName);
if (directory.exists()) {
if (!directory.isDirectory()) {
@@ -1007,8 +1007,8 @@
}
private void notifyImported() {
- numberOfImported+=storeSaver.getNumberOfModified();
- if( listener!=null) {
+ numberOfImported += storeSaver.getNumberOfModified();
+ if (listener != null) {
listener.numberOfImported(numberOfImported);
}
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImportListener.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImportListener.java 2011-09-30 01:09:49 UTC (rev 2909)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImportListener.java 2011-10-01 16:45:37 UTC (rev 2910)
@@ -25,7 +25,7 @@
/**
*
* @author luc peuvrier
- *
+ *
*/
public interface IImportListener {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java 2011-09-30 01:09:49 UTC (rev 2909)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java 2011-10-01 16:45:37 UTC (rev 2910)
@@ -68,7 +68,7 @@
throw new ImportException(exportFile + " does not exists");
}
final SAXParserFactory factory = SAXParserFactory.newInstance();
- //FIXMELUC _______________why not validating
+ // FIXMELUC _______________why not validating
factory.setValidating(false);
factory.setNamespaceAware(true);
final SchemaFactory schemaFactory = SchemaFactory
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-01 16:45:44
|
Revision: 2910
http://joafip.svn.sourceforge.net/joafip/?rev=2910&view=rev
Author: luc_peuvrier
Date: 2011-10-01 16:45:37 +0000 (Sat, 01 Oct 2011)
Log Message:
-----------
correction to access to protected constructor
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java
trunk/joafip/src/main/java/net/sf/joafip/service/AbstractDataAccessSession.java
trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/service/IDataAccessSessionCommon.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImportListener.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-09-30 01:09:57
|
Revision: 2909
http://joafip.svn.sourceforge.net/joafip/?rev=2909&view=rev
Author: luc_peuvrier
Date: 2011-09-30 01:09:49 +0000 (Fri, 30 Sep 2011)
Log Message:
-----------
added import listener
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
trunk/joafip/src/test/resources/log4j.properties
Added Paths:
-----------
trunk/joafip/doc/current.txt
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImportListener.java
Added: trunk/joafip/doc/current.txt
===================================================================
--- trunk/joafip/doc/current.txt (rev 0)
+++ trunk/joafip/doc/current.txt 2011-09-30 01:09:49 UTC (rev 2909)
@@ -0,0 +1,7 @@
+108738, 118200, 132948, 142808, 165872
+
+ 1 1010 1000 1100 0010
+ 1 1100 1101 1011 1000
+ 10 0000 0111 0101 0100
+1 0100 0010 1000 0000 1000
+ 10 1000 0111 1111 0000
\ No newline at end of file
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2011-09-30 01:07:17 UTC (rev 2908)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2011-09-30 01:09:49 UTC (rev 2909)
@@ -54,6 +54,7 @@
import net.sf.joafip.store.service.StoreInvalidClassException;
import net.sf.joafip.store.service.StoreNotSerializableException;
import net.sf.joafip.store.service.StoreTooBigForSerializationException;
+import net.sf.joafip.store.service.export_import.in.IImportListener;
import net.sf.joafip.store.service.objectio.manager.ISubsituteSynchronizer;
import net.sf.joafip.store.service.objectio.serialize.input.IObjectInput;
import net.sf.joafip.store.service.objectio.serialize.output.IObjectOutput;
@@ -1755,6 +1756,11 @@
}
}
+ @Override
+ public void setImportListener(final IImportListener listener) {
+ store.setImportListener(listener);
+ }
+
/**
* assert there is no object stored
*
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2011-09-30 01:07:17 UTC (rev 2908)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2011-09-30 01:09:49 UTC (rev 2909)
@@ -30,6 +30,7 @@
import net.sf.joafip.heapfile.record.entity.DataRecordIdentifier;
import net.sf.joafip.store.entity.classinfo.ClassInfo;
import net.sf.joafip.store.service.IGarbageListener;
+import net.sf.joafip.store.service.export_import.in.IImportListener;
import net.sf.joafip.store.service.export_import.out.IExporterListener;
import net.sf.joafip.store.service.objectio.manager.ISubsituteSynchronizer;
import net.sf.joafip.store.service.objectio.manager.ISubstituteObjectManager;
@@ -665,6 +666,8 @@
void storedMutableEnum(Class<? extends Enum<?>>[] enumClasses)
throws FilePersistenceException;
+ void setImportListener(IImportListener listener);
+
/**
* declare persisted mutable enum by its class<br>
* (PROPS) can be set using properties file see
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java 2011-09-30 01:07:17 UTC (rev 2908)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java 2011-09-30 01:09:49 UTC (rev 2909)
@@ -52,6 +52,7 @@
import net.sf.joafip.store.service.copier.CopierException;
import net.sf.joafip.store.service.copier.DeepCopier;
import net.sf.joafip.store.service.copier.ToProxyDeepCopier;
+import net.sf.joafip.store.service.export_import.in.IImportListener;
import net.sf.joafip.store.service.export_import.in.IImporter;
import net.sf.joafip.store.service.export_import.in.ImportClassNotFoundException;
import net.sf.joafip.store.service.export_import.in.ImportDataCorruptedException;
@@ -514,6 +515,11 @@
}
@Override
+ public void setImportListener(final IImportListener listener) {
+ xmlImporter.setListener(listener);
+ }
+
+ @Override
public int getCurrentDataModelIdentifier() {
return currentDataModelIdentifier;
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2011-09-30 01:07:17 UTC (rev 2908)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2011-09-30 01:09:49 UTC (rev 2909)
@@ -44,6 +44,7 @@
import net.sf.joafip.store.service.conversion.def.ConversionManager;
import net.sf.joafip.store.service.copier.CopierException;
import net.sf.joafip.store.service.copier.IDeepCopyServiceDelegate;
+import net.sf.joafip.store.service.export_import.in.IImportListener;
import net.sf.joafip.store.service.export_import.out.IExporterListener;
import net.sf.joafip.store.service.garbage.GarbageManager;
import net.sf.joafip.store.service.garbage.recordmgr.LinkRecordManager;
@@ -668,6 +669,8 @@
StoreClassNotFoundException, StoreInvalidClassException,
StoreDataCorruptedException, StoreNotSerializableException;
+ void setImportListener(IImportListener listener);
+
Object newProxyInstance(Object object) throws StoreException;
Object newProxyInstance(Class<?> objectClass, Class<?>[] parameterTypes,
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java 2011-09-30 01:07:17 UTC (rev 2908)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java 2011-09-30 01:09:49 UTC (rev 2909)
@@ -123,6 +123,10 @@
private final int currentDataModelIdentifier;
+ private long numberOfImported;
+
+ private IImportListener listener;
+
public AbstractImporter(final IStore store) throws ImportException {
super();
try {
@@ -144,6 +148,11 @@
}
}
+ @Override
+ public void setListener(final IImportListener listener) {
+ this.listener = listener;
+ }
+
public ClassInfoFactory getClassInfoFactory() {
return classInfoFactory;
}
@@ -152,6 +161,7 @@
public void doImport(final String directoryName) throws ImportException,
ImportClassNotFoundException, ImportDataCorruptedException,
ImportInvalidClassException, ImportNotSerializableException {
+ numberOfImported=0;
final File directory = new File(directoryName);
if (directory.exists()) {
if (!directory.isDirectory()) {
@@ -228,69 +238,6 @@
}
}
- // /**
- // * Sets the field represented by this field object knew by its name on the
- // * specified object argument to the specified new value.
- // *
- // * @param object
- // * the object that own the field
- // * @param objectOwningFieldDef
- // * information on object owning field
- // * @param originalFieldName
- // * the new value for the field knew by its name of
- // * <code>object</code> being modified
- // * @param conversionFieldClassDef
- // * @param value
- // * the new value for the field of <code>object</code> being
- // * modified
- // * @throws ImportException
- // */
- // protected void setObjectField(final Object object,
- // final ConversionClassDef objectOwningFieldDef,
- // final String originalFieldName,
- // final ConversionClassDef conversionFieldClassDef,
- // final ConversionClassDef conversionFieldDeclaringClassDef,
- // final Object value) throws ImportException {
- // final ClassInfo fieldClassInfo =
- // conversionFieldClassDef.getOriginalClassInfo();
- // final FieldReplacementDef replacementFieldDef = replacementFieldName(
- // objectOwningFieldDef.getClassName(), originalFieldName,
- // fieldClassInfo.getName());
- // final String fieldName = replacementFieldDef.getFieldName();
- // if (!"".equals(fieldName)) {
- // /*
- // * not a deleted field
- // */
- // final Class<? extends Object> currentClass;
- // try {
- // final ObjectIoReplacementDef replacementDef;
- // if (conversionFieldDeclaringClassDef == null) {
- // currentClass=objectOwningFieldDef.getFinalClassInfo().getClass();
- // } else {
- // currentClass=conversionFieldDeclaringClassDef.getFinalClassInfo().getClass();
- // }
- //
- // } catch (ConversionException exception) {
- // throw new ImportException(exception);
- // }
- // // final Class<? extends Object> currentClass=object.getClass();
- // final Field field = searchField(currentClass, fieldName);
- // try {
- // //setFieldAccessible.set(field);
- // field.set(object, value);
- // } catch (IllegalArgumentException exception) {
- // throw new ImportException(setFieldMessage(object, field,
- // originalFieldName, value), exception);
- // } catch (IllegalAccessException exception) {
- // throw new ImportException(setFieldMessage(object, field,
- // originalFieldName, value), exception);
- // } catch (SecurityException exception) {
- // throw new ImportException(setFieldMessage(object, field,
- // originalFieldName, value), exception);
- // }
- // }
- // }
-
@SuppressWarnings("unused")
private String setFieldMessage(final Object object, final Field field,
final String originalFieldName, final Object value) {
@@ -1038,6 +985,7 @@
try {
storeSaver.setRootOfObjectsToSave(object);
storeSaver.saveForImport(/* object, */dummyObjectSet);
+ notifyImported();
objectIOManager.clearObjectState();
} catch (final StoreException exception) {
throw new ImportException(exception);
@@ -1058,6 +1006,13 @@
dummyObjectSet.clear();
}
+ private void notifyImported() {
+ numberOfImported+=storeSaver.getNumberOfModified();
+ if( listener!=null) {
+ listener.numberOfImported(numberOfImported);
+ }
+ }
+
/**
* record class static field
*
@@ -1083,6 +1038,7 @@
dataRecordIdentifier);
storeSaver.setRootOfObjectsToSave(null);
storeSaver.saveForImport(/* null, */dummyObjectSet);
+ notifyImported();
objectIOManager.clearObjectState();
} catch (final ObjectIOException exception) {
Added: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImportListener.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImportListener.java (rev 0)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImportListener.java 2011-09-30 01:09:49 UTC (rev 2909)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.service.export_import.in;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public interface IImportListener {
+
+ void numberOfImported(long numberOfImported);
+
+}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImporter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImporter.java 2011-09-30 01:07:17 UTC (rev 2908)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImporter.java 2011-09-30 01:09:49 UTC (rev 2909)
@@ -29,6 +29,8 @@
*/
public interface IImporter {
+ void setListener(IImportListener listener);
+
/**
* import from exported data in <code>directoryName<code> directory<br>
*
@@ -51,5 +53,4 @@
ImportException, ImportClassNotFoundException,
ImportDataCorruptedException, ImportInvalidClassException,
ImportNotSerializableException;
-
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java 2011-09-30 01:07:17 UTC (rev 2908)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java 2011-09-30 01:09:49 UTC (rev 2909)
@@ -68,6 +68,7 @@
throw new ImportException(exportFile + " does not exists");
}
final SAXParserFactory factory = SAXParserFactory.newInstance();
+ //FIXMELUC _______________why not validating
factory.setValidating(false);
factory.setNamespaceAware(true);
final SchemaFactory schemaFactory = SchemaFactory
Modified: trunk/joafip/src/test/resources/log4j.properties
===================================================================
--- trunk/joafip/src/test/resources/log4j.properties 2011-09-30 01:07:17 UTC (rev 2908)
+++ trunk/joafip/src/test/resources/log4j.properties 2011-09-30 01:09:49 UTC (rev 2909)
@@ -128,6 +128,7 @@
#log4j.logger.net.sf.joafip.service.bug.emis.TestEmis=debug
log4j.logger.net.sf.joafip.performance.items.service.Inserter=info
log4j.logger.net.sf.joafip.performance.items.service.Searcher=info
+log4j.logger.net.sf.joafip.performance.items.service.ImportSearcher=info
log4j.logger.net.sf.joafip.service.MainCrash=info
log4j.logger.net.sf.joafip.service.MainAfterCrash=info
log4j.logger.net.sf.joafip.service.MainWarnDataRecord1=debug
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-09-30 01:09:56
|
Revision: 2909
http://joafip.svn.sourceforge.net/joafip/?rev=2909&view=rev
Author: luc_peuvrier
Date: 2011-09-30 01:09:49 +0000 (Fri, 30 Sep 2011)
Log Message:
-----------
added import listener
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
trunk/joafip/src/test/resources/log4j.properties
Added Paths:
-----------
trunk/joafip/doc/current.txt
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImportListener.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-09-30 01:07:24
|
Revision: 2908
http://joafip.svn.sourceforge.net/joafip/?rev=2908&view=rev
Author: luc_peuvrier
Date: 2011-09-30 01:07:17 +0000 (Fri, 30 Sep 2011)
Log Message:
-----------
constructor are now public
Modified Paths:
--------------
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PSubList.java
Modified: trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PSubList.java
===================================================================
--- trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PSubList.java 2011-09-26 08:02:05 UTC (rev 2907)
+++ trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PSubList.java 2011-09-30 01:07:17 UTC (rev 2908)
@@ -46,12 +46,12 @@
private int size;// NOPMD
- private PSubList(final List<E> list, final int fromIndex, final int toIndex) {
+ public PSubList(final List<E> list, final int fromIndex, final int toIndex) {
this((IInstanceFactory) null, list, fromIndex, toIndex);
}
- private PSubList(final IInstanceFactory instanceFactory,
- final List<E> list, final int fromIndex, final int toIndex) {
+ public PSubList(final IInstanceFactory instanceFactory, final List<E> list,
+ final int fromIndex, final int toIndex) {
super(instanceFactory);
if (fromIndex < 0) {
throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-09-30 01:07:24
|
Revision: 2908
http://joafip.svn.sourceforge.net/joafip/?rev=2908&view=rev
Author: luc_peuvrier
Date: 2011-09-30 01:07:17 +0000 (Fri, 30 Sep 2011)
Log Message:
-----------
constructor are now public
Modified Paths:
--------------
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PSubList.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|