[jboss-cvs] JBoss Profiler SVN: r557 - in branches/JBossProfiler2: .settings and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 11 17:05:44 EDT 2009


Author: clebert.suconic at jboss.com
Date: 2009-08-11 17:05:43 -0400 (Tue, 11 Aug 2009)
New Revision: 557

Added:
   branches/JBossProfiler2/.settings/
   branches/JBossProfiler2/.settings/de.loskutov.anyedit.AnyEditTools.prefs
   branches/JBossProfiler2/.settings/intellij_settings.jar
   branches/JBossProfiler2/.settings/org.eclipse.jdt.core.prefs
   branches/JBossProfiler2/.settings/org.eclipse.jdt.ui.prefs
   branches/JBossProfiler2/.settings/org.eclipse.ltk.core.refactoring.prefs
   branches/JBossProfiler2/lib/junit-4.4.jar
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/InventoryDataPoint.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTICallBack.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTITypes.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/ReferenceDataPoint.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/MemoryProfilerEmbedded.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java
   branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/
   branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java
Modified:
   branches/JBossProfiler2/
   branches/JBossProfiler2/.classpath
   branches/JBossProfiler2/build.xml
   branches/JBossProfiler2/src/native/
   branches/JBossProfiler2/src/native/agent.cpp
   branches/JBossProfiler2/src/native/agent.h
Log:
Adding a jvmti module with HTTP memory profiler that I used to find leaks on JBoss Messaging


Property changes on: branches/JBossProfiler2
___________________________________________________________________
Name: svn:ignore
   - build
dist
reports
*.zip
*.tar.gz
*.tar.bz2
CMakeCache.txt
cmake_install.cmake
CMakeFiles
Makefile
*.patch


   + bin
build
dist
reports
*.zip
*.tar.gz
*.tar.bz2
CMakeCache.txt
cmake_install.cmake
CMakeFiles
Makefile
*.patch



Modified: branches/JBossProfiler2/.classpath
===================================================================
--- branches/JBossProfiler2/.classpath	2009-06-24 15:17:45 UTC (rev 556)
+++ branches/JBossProfiler2/.classpath	2009-08-11 21:05:43 UTC (rev 557)
@@ -1,17 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src/main"/>
-	<classpathentry kind="src" path="src/test"/>
-	<classpathentry kind="lib" path="lib/asm.jar"/>
+	<classpathentry kind="src" path="src/test/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="lib" path="lib/commons-beanutils.jar"/>
+	<classpathentry kind="lib" path="lib/commons-digester.jar"/>
 	<classpathentry kind="lib" path="lib/concurrent.jar"/>
 	<classpathentry kind="lib" path="lib/ejb3-persistence.jar"/>
+	<classpathentry kind="lib" path="lib/javassist.jar"/>
 	<classpathentry kind="lib" path="lib/jboss-common.jar"/>
 	<classpathentry kind="lib" path="lib/jboss-ejb3x.jar"/>
 	<classpathentry kind="lib" path="lib/jboss-remoting.jar"/>
 	<classpathentry kind="lib" path="lib/jbossall-client.jar"/>
+	<classpathentry kind="lib" path="lib/jsf-api.jar"/>
+	<classpathentry kind="lib" path="lib/jsf-facelets.jar"/>
+	<classpathentry kind="lib" path="lib/jsf-impl.jar"/>
 	<classpathentry kind="lib" path="lib/log4j.jar"/>
+	<classpathentry kind="lib" path="lib/richfaces-api.jar"/>
+	<classpathentry kind="lib" path="lib/richfaces-impl.jar"/>
+	<classpathentry kind="lib" path="lib/richfaces-ui.jar"/>
 	<classpathentry kind="lib" path="lib/servlet.jar"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="lib" path="lib/javassist.jar"/>
+	<classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Added: branches/JBossProfiler2/.settings/de.loskutov.anyedit.AnyEditTools.prefs
===================================================================
--- branches/JBossProfiler2/.settings/de.loskutov.anyedit.AnyEditTools.prefs	                        (rev 0)
+++ branches/JBossProfiler2/.settings/de.loskutov.anyedit.AnyEditTools.prefs	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,15 @@
+#Wed Sep 17 15:35:39 BST 2008
+activeContentFilterList=*.makefile,makefile,*.Makefile,Makefile,Makefile.*,*.mk,MANIFEST.MF
+convertActionOnSaave=AnyEdit.CnvrtTabToSpaces
+eclipse.preferences.version=1
+inActiveContentFilterList=
+javaTabWidthForJava=true
+org.eclipse.jdt.ui.editor.tab.width=3
+projectPropsEnabled=true
+removeTrailingSpaces=true
+replaceAllSpaces=false
+replaceAllTabs=false
+saveAndAddLine=false
+saveAndConvert=true
+saveAndTrim=true
+useModulo4Tabs=false

Added: branches/JBossProfiler2/.settings/intellij_settings.jar
===================================================================
(Binary files differ)


Property changes on: branches/JBossProfiler2/.settings/intellij_settings.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/JBossProfiler2/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- branches/JBossProfiler2/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ branches/JBossProfiler2/.settings/org.eclipse.jdt.core.prefs	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,274 @@
+#Sat Sep 27 08:56:30 BST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+org.eclipse.jdt.core.codeComplete.fieldPrefixes=
+org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+org.eclipse.jdt.core.codeComplete.localPrefixes=
+org.eclipse.jdt.core.codeComplete.localSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=optimize out
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=82
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=82
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=82
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=82
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=82
+org.eclipse.jdt.core.formatter.alignment_for_assignment=82
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=82
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=82
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=82
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=82
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=82
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=82
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=82
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=82
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=82
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=82
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=82
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=1
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=0
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true
+org.eclipse.jdt.core.formatter.comment.format_block_comments=false
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
+org.eclipse.jdt.core.formatter.comment.line_length=120
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=3
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=3
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.indentation.size=3
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=true
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=120
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false
+org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=3
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=false

Added: branches/JBossProfiler2/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- branches/JBossProfiler2/.settings/org.eclipse.jdt.ui.prefs	                        (rev 0)
+++ branches/JBossProfiler2/.settings/org.eclipse.jdt.ui.prefs	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,110 @@
+#Wed Feb 25 14:56:24 CET 2009
+cleanup.add_default_serial_version_id=false
+cleanup.add_generated_serial_version_id=true
+cleanup.add_missing_annotations=true
+cleanup.add_missing_deprecated_annotations=true
+cleanup.add_missing_nls_tags=false
+cleanup.add_missing_override_annotations=true
+cleanup.add_serial_version_id=true
+cleanup.always_use_blocks=true
+cleanup.always_use_parentheses_in_expressions=false
+cleanup.always_use_this_for_non_static_field_access=false
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_to_enhanced_for_loop=true
+cleanup.format_source_code=true
+cleanup.make_local_variable_final=false
+cleanup.make_parameters_final=true
+cleanup.make_private_fields_final=true
+cleanup.make_variable_declarations_final=true
+cleanup.never_use_blocks=false
+cleanup.never_use_parentheses_in_expressions=true
+cleanup.organize_imports=true
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=true
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_trailing_whitespaces=true
+cleanup.remove_trailing_whitespaces_all=true
+cleanup.remove_trailing_whitespaces_ignore_empty=false
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=true
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=true
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.sort_members=false
+cleanup.sort_members_all=false
+cleanup.use_blocks=true
+cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_parentheses_in_expressions=true
+cleanup.use_this_for_non_static_field_access=true
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=true
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_JBM
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false
+formatter_profile=_JBM
+formatter_settings_version=11
+org.eclipse.jdt.ui.exception.name=e
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=java;javax;com;org;
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.ondemandthreshold=9999
+org.eclipse.jdt.ui.overrideannotation=true
+org.eclipse.jdt.ui.staticondemandthreshold=9999
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" delete!
 d\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment"></template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * A ${type_name}\n *\n * @author ${user}\n *\n * ${tags}\n *\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overrideco!
 mment_context" deleted\="false" description\="Comment for over!
 riding m
ethods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">/*\n * JBoss, Home of Professional Open Source\n * Copyright 2005-${year}, Red Hat Middleware LLC, and individual contributors\n * by the @authors tag. See the copyright.txt in the distribution for a\n * full listing of individual contributors.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser!
  General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site\: http\://www.fsf.org.\n */\n\n\n${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="false" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbod!
 y">\n   // Constants -----------------------------------------!
 --------
----\n\n   // Attributes ----------------------------------------------------\n\n   // Static --------------------------------------------------------\n\n   // Constructors --------------------------------------------------\n\n   // Public --------------------------------------------------------\n\n   // Package protected ---------------------------------------------\n\n   // Protected -----------------------------------------------------\n\n   // Private -------------------------------------------------------\n\n   // Inner classes -------------------------------------------------\n\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclips!
 e.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created !
 constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.tex!
 t.codete
mplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=true
+sp_cleanup.format_source_code=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=true
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=false
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=true
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=true
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=true
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=true
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true

Added: branches/JBossProfiler2/.settings/org.eclipse.ltk.core.refactoring.prefs
===================================================================
--- branches/JBossProfiler2/.settings/org.eclipse.ltk.core.refactoring.prefs	                        (rev 0)
+++ branches/JBossProfiler2/.settings/org.eclipse.ltk.core.refactoring.prefs	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,3 @@
+#Wed Sep 17 15:45:12 BST 2008
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false

Modified: branches/JBossProfiler2/build.xml
===================================================================
--- branches/JBossProfiler2/build.xml	2009-06-24 15:17:45 UTC (rev 556)
+++ branches/JBossProfiler2/build.xml	2009-08-11 21:05:43 UTC (rev 557)
@@ -12,6 +12,8 @@
     <property name="dist.dir" value="${basedir}/dist"/>
     <property name="tools.dir" value="${basedir}/tools"/>
     <property name="reports.dir" value="${basedir}/reports"/>
+	
+	<property name="native-src-dir" value="./src/native"/>
 
     <property name="name" value="jboss-profiler"/>
     <property name="major" value="2"/>
@@ -24,6 +26,7 @@
     <property name="jboss-profiler-connectors.jar" value="jboss-profiler-connectors.jar"/>
     <property name="jboss-profiler-client.jar" value="jboss-profiler-client.jar"/>
     <property name="jboss-profiler-embedded.jar" value="jboss-profiler-embedded.jar"/>
+	<property name="jboss-profiler-jvmti.jar" value="jboss-profiler-jvmti.jar"/>
     <property name="jboss-profiler-plugins.jar" value="jboss-profiler-plugins.jar"/>
     <property name="jboss-profiler-precompiler.jar" value="jboss-profiler-precompiler.jar"/>
     <property name="jboss-profiler-test.jar" value="jboss-profiler-test.jar"/>
@@ -226,6 +229,52 @@
     </target>
 
     <!-- =================================================================== -->
+    <!-- Embedded                                                            -->
+    <!-- =================================================================== -->
+    <target name="jvmti" depends="prepare">
+        <delete dir="${build.dir}"/>
+        <mkdir dir="${build.dir}"/>
+        <javac
+            destdir="${build.dir}"
+            classpathref="class.path"
+            debug="on"
+            deprecation="on"
+            optimize="off"
+            source="1.5"
+            target="1.5"
+        	depend="false"
+        	failonerror="true"
+            >
+            <src path="${src.main.dir}">
+        	</src>
+    			<include name="org/jboss/profiler/jvmti/**/*.java" />
+        	
+        </javac>
+     	
+        <copy todir="${build.dir}">
+            <fileset dir="${etc.dir}">
+               <include name="**/jboss-profiler.properties"/>
+               <include name="**/log4j.xml"/>
+            </fileset>
+        </copy>
+
+        <unzip src="${lib.dir}/jboss-common.jar" dest="${build.dir}">
+          <patternset>
+            <include name="org/jboss/logging/**"/>
+          </patternset>
+        </unzip>
+
+        <jar destfile="${dist.dir}/${jboss-profiler-jvmti.jar}"
+             basedir="${build.dir}"
+             manifest="${etc.dir}/embedded-manifest.mf"
+             includes="org/jboss/profiler/jvmti/**"
+             excludes="**/*.java"/>
+
+    	<javah class="org.jboss.profiler.jvmti.JVMTIInterface"  destdir="${native-src-dir}" classpathref="test.class.path"/>
+    	
+    </target>
+
+    <!-- =================================================================== -->
     <!-- Plugins                                                             -->
     <!-- =================================================================== -->
     <target name="plugins" depends="prepare">
@@ -443,7 +492,7 @@
     <!-- =================================================================== -->
     <!-- Dist                                                                -->
     <!-- =================================================================== -->
-    <target name="dist" depends="agent,connectors,ant,client,embedded,plugins,precompiler,test,sar">
+    <target name="dist" depends="agent,connectors,ant,client,embedded,jvmti,plugins,precompiler,test,sar">
         <copy todir="${dist.dir}">
             <fileset dir="${lib.dir}">
                <include name="**/*.jar"/>

Added: branches/JBossProfiler2/lib/junit-4.4.jar
===================================================================
(Binary files differ)


Property changes on: branches/JBossProfiler2/lib/junit-4.4.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/InventoryDataPoint.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/InventoryDataPoint.java	                        (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/InventoryDataPoint.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,98 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.profiler.jvmti;
+
+import java.lang.ref.WeakReference;
+
+/**
+ * Used to return quantity of instances and bytes per class 
+ *  */
+public class InventoryDataPoint implements Comparable
+{
+
+   public InventoryDataPoint(final Class clazz)
+   {
+      this.clazz = new WeakReference(clazz);
+   }
+
+   public InventoryDataPoint(final Class clazz, final int instances)
+   {
+      this.clazz = new WeakReference(clazz);
+      this.instances = instances;
+   }
+
+   WeakReference clazz;
+
+   int instances;
+
+   long bytes;
+
+   public long getBytes()
+   {
+      return bytes;
+   }
+
+   public void setBytes(final long bytes)
+   {
+      this.bytes = bytes;
+   }
+
+   public Class getClazz()
+   {
+      return (Class)clazz.get();
+   }
+
+   public void setClazz(final Class clazz)
+   {
+      this.clazz = new WeakReference(clazz);
+   }
+
+   public int getInstances()
+   {
+      return instances;
+   }
+
+   public void setInstances(final int instances)
+   {
+      this.instances = instances;
+   }
+
+   public int compareTo(final Object o)
+   {
+      InventoryDataPoint that = (InventoryDataPoint)o;
+      long result = that.bytes - bytes;
+      if (result == 0)
+      {
+         return 0;
+      }
+      else if (result > 0)
+      {
+         return 1;
+      }
+      else
+      {
+         return -1;
+      }
+   }
+
+}

Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTICallBack.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTICallBack.java	                        (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTICallBack.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,51 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.profiler.jvmti;
+
+/** 
+ * Interface to get notifications for references on JVMTI
+ * @author csuconic
+ *
+ */
+public interface JVMTICallBack
+{
+   /**
+    *JNISignature for this method = (JJJJJB)V
+    * @param referenceHolder A tag id of an object  (if -1 means the root)
+    * @param referencedObject A tag id of an object
+    * @param fieldId A tag id for a Field referencing the object. If -1 that means a static reference in a method
+    */
+   public void notifyReference(long referenceHolder,
+                               long referencedObject,
+                               long classTag,
+                               long index,
+                               long method,
+                               byte referenceType);
+
+   /** Notifications of loaded classes*/
+   public void notifyClass(long classTag, Class<?> clazz);
+
+   /** Notifications of loaded classes*/
+   public void notifyObject(long classTag, long objectId, long bytes);
+
+}

Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java	                        (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,1399 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profiler.jvmti;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayWriter;
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Field;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeSet;
+import java.util.WeakHashMap;
+import java.util.concurrent.CountDownLatch;
+
+import org.jboss.profiler.jvmti.memoryweb.MemoryProfilerEmbedded;
+
+/**
+ * @author Clebert Suconic
+ */
+public class JVMTIInterface
+{
+   private static boolean isLoaded = true;
+   static
+   {
+      try
+      {
+         System.loadLibrary("JBossProfiler");
+      }
+      catch (Throwable e)
+      {
+         isLoaded = false;
+         System.out.println("The DLL/SO couldn't be loaded, you won't be able to use any JVMTIInterface feature");
+      }
+   }
+
+   /**
+    * Force a GC. This method doesn't use System.gc. If JVMTI is enabled this
+    * will really cause a FullGC by calling a JVMTI function.
+    */
+   public native void forceGC();
+
+   public native void startMeasure(String directory, String prefix, String suffix);
+
+   public native void stopMeasure();
+
+   /** returns the first class found with a given name */
+   public Class<?> getClassByName(final String className)
+   {
+      Class<?> classes[] = getLoadedClasses();
+
+      for (Class<?> classe : classes)
+      {
+         if (classe.getName().equals(className))
+         {
+            return classe;
+         }
+      }
+
+      return null;
+   }
+
+   /**
+    * Will release internal tags used by previous methods. All the navigations
+    * through JVMTI are done through tagging. Calling this method will release
+    * any tagging done by previous methods.
+    */
+   public native void releaseTags();
+
+   /**
+    * This method will keep every object tagged for later usage. This method is
+    * going to tag objects.
+    */
+   protected native void notifyInventory(boolean notifyOnClasses,
+                                         String temporaryFileReferences,
+                                         String temporaryFileObjects,
+                                         JVMTICallBack callback);
+
+   public void notifyOnReferences(final String temporaryFile, final JVMTICallBack callback)
+   {
+      notifyInventory(true, temporaryFile, null, callback);
+   }
+
+   /**
+    * Will get all the objects holding references to these objects passed by
+    * parameter. This method is going to release tags, be careful if you are on
+    * the middle of navigations.
+    */
+   public native Object[] getReferenceHolders(Object[] objects);
+
+   public native Class<?>[] getLoadedClasses();
+
+   /**
+    * Will return all methods of a give class. This will change tags, be
+    * careful if you are on the middle of navigations.
+    */
+   public native Object[] getAllObjects(Class<?> clazz);
+
+   /** Will return the tag of an object */
+   public native long getTagOnObject(Object obj);
+
+   /** Will return the object on a tag */
+   public native Object getObjectOnTag(long tag);
+
+   private native boolean internalIsConfiguredProperly();
+
+   /** Returns true if -agentlib:JBossProfiler was configured properly */
+   public boolean isActive()
+   {
+      if (!isLoaded)
+      {
+         return false;
+      }
+      else
+      {
+         return internalIsConfiguredProperly();
+      }
+   }
+
+   /**
+    * Returns the field represted by the FieldId. This is used on field
+    * relationships according to the rule determined by JVMTI documentation.
+    */
+   public Field getObjectField(Class<?> clazz, int fieldId)
+   {
+      ArrayList<Class<?>> list = new ArrayList<Class<?>>();
+      list.add(clazz);
+      while ((clazz = clazz.getSuperclass()) != null)
+      {
+         list.add(clazz);
+      }
+
+      for (int i = list.size() - 1; i >= 0; i--)
+      {
+         Field fields[] = ((Class)list.get(i)).getDeclaredFields();
+         if (fieldId < fields.length)
+         {
+            return fields[fieldId];
+         }
+         fieldId -= fields.length;
+      }
+      return null;
+   }
+
+   public native String getMethodName(long methodId);
+
+   public native String getMethodSignature(long methodId);
+
+   public native Class getMethodClass(long methodId);
+
+   protected static native void heapSnapshot(String classesFileName, String referencesFileName, String objectsFileName);
+
+   /**
+    * Will call {@link JVMTIInterface.heapSnapshot(String,String,String)}
+    * passing "_classes, _references, _objects in the name of the files
+    */
+   public void heapSnapshot(final String basicFileName, final String suffix)
+   {
+      forceGC();
+      heapSnapshot(basicFileName + "_classes" + "." + suffix,
+                   basicFileName + "_references" + "." + suffix,
+                   basicFileName + "_objects" + "." + suffix);
+   }
+
+   /**
+    * Return every single object on a give class by its name. This method will
+    * look for every single class with this name, and if more than one
+    * classLoader is loading a class with this name, this method will return
+    * objects for all the respective classes. For example if you look for a
+    * Structs Action Form, this will return every ActionForm defined on the
+    * current JVM.
+    */
+   public Object[] getAllObjects(final String clazz)
+   {
+      ArrayList list = new ArrayList();
+
+      Class[] classes = getLoadedClasses();
+      for (Class classe : classes)
+      {
+         if (classe.getName().equals(clazz))
+         {
+            Object objs[] = this.getAllObjects(classe);
+            for (Object obj : objs)
+            {
+               list.add(obj);
+            }
+         }
+      }
+
+      return list.toArray();
+   }
+
+   static class ClassSorterByClassLoader implements Comparator
+   {
+
+      public int compare(final Object o1, final Object o2)
+      {
+         Class left = (Class)o1;
+         Class right = (Class)o2;
+
+         int compare = 0;
+
+         if ((compare = compareClassLoader(left.getClassLoader(), right.getClassLoader())) != 0)
+         {
+            return compare;
+         }
+
+         return left.getName().compareTo(right.getName());
+      }
+
+      public int compareClassLoader(final ClassLoader left, final ClassLoader right)
+      {
+         if (left == null || right == null)
+         {
+            if (left == right)
+            {
+               return 0;
+            }
+            else if (left == null)
+            {
+               return -1;
+            }
+            else
+            {
+               return 1;
+            }
+         }
+         else
+         {
+            return left.toString().compareTo(right.toString());
+         }
+      }
+
+   }
+
+   static class ClassSorterByClassName implements Comparator
+   {
+
+      public int compare(final Object o1, final Object o2)
+      {
+         Class left = (Class)o1;
+         Class right = (Class)o2;
+         int compare = left.getName().compareTo(right.getName());
+         /*
+          * if (compare==0) { if (o1==o2) { return 0; } else { return 1; } }
+          * else { return compare; }
+          */
+         return compare;
+      }
+   }
+
+   public String convertToString(final Object obj, final boolean callToString)
+   {
+
+      String returnValue = null;
+      try
+      {
+         if (obj == null)
+         {
+            returnValue = "null";
+         }
+         else
+         {
+            if (callToString)
+            {
+               returnValue = "TOSTRING(" + obj.toString() + "), class=" + obj.getClass().getName();
+            }
+            else
+            {
+               if (obj instanceof Class)
+               {
+                  returnValue = "CLASS(" + obj.toString() + "), identifyHashCode=" + System.identityHashCode(obj);
+               }
+               else
+               {
+                  returnValue = "OBJ(" + obj.getClass().getName() + "@" + System.identityHashCode(obj) + ")";
+               }
+            }
+         }
+      }
+      catch (Throwable e)
+      {
+         return obj.getClass().getName() + " toString had an Exception ";
+      }
+
+      if (returnValue.length() > 200)
+      {
+         return "OBJ(" + obj.getClass().getName() + "@" + System.identityHashCode(obj) + ")";
+      }
+      else
+      {
+         return returnValue;
+      }
+   }
+
+   /** Explore references recursevely */
+   private void exploreObject(final PrintWriter out,
+                              final Object source,
+                              final int currentLevel,
+                              final int maxLevel,
+                              final boolean useToString,
+                              final boolean weakAndSoft,
+                              final Map mapDataPoints,
+                              final HashSet alreadyExplored)
+   {
+      String level = null;
+      {
+         StringBuffer levelStr = new StringBuffer();
+         for (int i = 0; i <= currentLevel; i++)
+         {
+            levelStr.append("!--");
+         }
+         level = levelStr.toString();
+      }
+
+      if (maxLevel >= 0 && currentLevel >= maxLevel)
+      {
+         out.println("<br>" + level + "<b>MaxLevel</b>");
+         return;
+      }
+      Integer index = new Integer(System.identityHashCode(source));
+
+      if (alreadyExplored.contains(index))
+      {
+         if (source instanceof Class)
+         {
+            out.println("<br>" + level +
+                        " object instanceOf " +
+                        source +
+                        "@" +
+                        index +
+                        " was already described before on this report");
+         }
+         else
+         {
+            out.println("<br>" + level +
+                        " object instanceOf " +
+                        source.getClass() +
+                        "@" +
+                        index +
+                        " was already described before on this report");
+         }
+         return;
+      }
+
+      alreadyExplored.add(index);
+
+      Long sourceTag = new Long(getTagOnObject(source));
+      ArrayList listPoints = (ArrayList)mapDataPoints.get(sourceTag);
+      if (listPoints == null)
+      {
+         return;
+      }
+
+      Iterator iter = listPoints.iterator();
+
+      while (iter.hasNext())
+      {
+         ReferenceDataPoint point = (ReferenceDataPoint)iter.next();
+
+         Object nextReference = treatReference(level, out, point, useToString);
+
+         if (nextReference != null && !weakAndSoft)
+         {
+            if (nextReference instanceof WeakReference || nextReference instanceof SoftReference)
+            {
+               nextReference = null;
+            }
+         }
+
+         if (nextReference != null)
+         {
+            exploreObject(out,
+                          nextReference,
+                          currentLevel + 1,
+                          maxLevel,
+                          useToString,
+                          weakAndSoft,
+                          mapDataPoints,
+                          alreadyExplored);
+         }
+      }
+
+   }
+
+   /**
+    * This is used by JSPs to have access to internal features formating
+    * results according to the navigations. That's the only reason this method
+    * is public. This is not intended to be used as part of the public API.
+    * 
+    * @urlBaseToFollow will be concatenated objId=3> obj </a> to the
+    *                  outputStream
+    */
+   public Object treatReference(final String level,
+                                final PrintWriter out,
+                                final ReferenceDataPoint point,
+                                final boolean useToString)
+   {
+      Object referenceHolder = null;
+      if (point.getReferenceHolder() == 0 || point.getReferenceHolder() == -1)
+      {
+         referenceHolder = null;
+      }
+      else
+      {
+         referenceHolder = getObjectOnTag(point.getReferenceHolder());
+      }
+      Object nextReference = null;
+      switch (point.getReferenceType())
+      {
+         case JVMTITypes.JVMTI_REFERENCE_INSTANCE:
+            ;// Reference from an object to its class.
+            out.println("<br>" + level +
+                        "InstanceOfReference:ToString=" +
+                        convertToString(referenceHolder, useToString));
+
+            nextReference = referenceHolder;
+            break;
+         case JVMTITypes.JVMTI_REFERENCE_FIELD:// Reference from an object to the
+            // value of one of its instance
+            // fields. For references of this kind the referrer_index parameter
+            // to
+            // the jvmtiObjectReferenceCallback is the index of the the instance
+            // field. The index is based on the order of all the object's
+            // fields.
+            // This includes all fields of the directly declared static and
+            // instance fields in the class, and includes all fields (both
+            // public
+            // and private) fields declared in superclasses and superinterfaces.
+            // The index is thus calculated by summing the index of field in the
+            // directly declared class (see GetClassFields), with the total
+            // number
+            // of fields (both public and private) declared in all superclasses
+            // and superinterfaces. The index starts at zero.
+         {
+
+            String fieldName = null;
+
+            if (referenceHolder == null)
+            {
+               fieldName = "Reference GONE";
+            }
+            else
+            {
+               Class clazz = referenceHolder.getClass();
+               Field field = getObjectField(clazz, (int)point.getIndex());
+               if (field == null)
+               {
+                  fieldName = "UndefinedField@" + referenceHolder;
+               }
+               else
+               {
+                  fieldName = field.toString();
+               }
+            }
+            out.println("<br>" + level +
+                        " FieldReference " +
+                        fieldName +
+                        "=" +
+                        convertToString(referenceHolder, useToString));
+            nextReference = referenceHolder;
+            break;
+         }
+         case JVMTITypes.JVMTI_REFERENCE_ARRAY_ELEMENT:// Reference from an array
+            // to one of its
+            // elements. For
+            // references of this kind the referrer_index parameter to the
+            // jvmtiObjectReferenceCallback is the array index.
+            if (referenceHolder == null)
+            {
+               out.println("<br>" + level + " arrayRef Position " + point.getIndex() + " is gone");
+            }
+            else
+            {
+               out.println("<br>" + level +
+                           " arrayRef " +
+                           referenceHolder.getClass().getName() +
+                           "[" +
+                           point.getIndex() +
+                           "] id=@" +
+                           System.identityHashCode(referenceHolder));
+            }
+            nextReference = referenceHolder;
+            break;
+         case JVMTITypes.JVMTI_REFERENCE_CLASS_LOADER:// Reference from a class
+            // to its class loader.
+            out.println("<br>" + level + "ClassLoaderReference @ " + convertToString(referenceHolder, useToString));
+            nextReference = referenceHolder;
+            break;
+         case JVMTITypes.JVMTI_REFERENCE_SIGNERS:// Reference from a class to its
+            // signers array.
+            out.println("<br>" + level + "ReferenceSigner@" + convertToString(referenceHolder, useToString));
+            nextReference = referenceHolder;
+            break;
+         case JVMTITypes.JVMTI_REFERENCE_PROTECTION_DOMAIN:// Reference from a
+            // class to its
+            // protection
+            // domain.
+            out.println("<br>" + level + "ProtectionDomain@" + convertToString(referenceHolder, useToString));
+            nextReference = referenceHolder;
+            break;
+         case JVMTITypes.JVMTI_REFERENCE_INTERFACE:// Reference from a class to
+            // one of its interfaces.
+            out.println("<br>" + level + "ReferenceInterface@" + convertToString(referenceHolder, useToString));
+            nextReference = referenceHolder;
+            break;
+         case JVMTITypes.JVMTI_REFERENCE_STATIC_FIELD:// Reference from a class
+            // to the value of one
+            // of its static
+            // fields. For references of this kind the referrer_index
+            // parameter to the jvmtiObjectReferenceCallback is the index
+            // of the static field. The index is based on the order of the
+            // directly declared static and instance fields in the class
+            // (not inherited fields), starting at zero. See
+            // GetClassFields.
+         {
+            Class clazz = (Class)referenceHolder;
+            Field field = getObjectField(clazz, (int)point.getIndex());
+            String fieldName = null;
+            if (field == null)
+            {
+               fieldName = "UndefinedField@" + referenceHolder;
+            }
+            else
+            {
+               fieldName = field.toString();
+            }
+            out.println("<br>" + level + " StaticFieldReference " + fieldName);
+            nextReference = null;
+            break;
+         }
+         case JVMTITypes.JVMTI_REFERENCE_CONSTANT_POOL:// Reference from a class
+            // to a resolved entry
+            // in the constant
+            // pool. For references of this kind the referrer_index
+            // parameter to the jvmtiObjectReferenceCallback is the index
+            // into constant pool table of the class, starting at 1. See
+            // The Constant Pool in the Java Virtual Machine
+            // Specification.
+            out.println("<br>" + level + "ReferenceInterface@" + convertToString(referenceHolder, useToString));
+            nextReference = referenceHolder;
+            break;
+         case JVMTITypes.ROOT_REFERENCE:
+            out.println("<br>" + level + "Root");
+            nextReference = null;
+            break;
+         case JVMTITypes.THREAD_REFERENCE:
+
+            Class methodClass = getMethodClass(point.getMethod());
+            if (methodClass != null)
+            {
+               String className = null;
+               if (methodClass != null)
+               {
+                  className = methodClass.getName();
+               }
+
+               String methodName = getMethodName(point.getMethod());
+               out.println("<br>" + level + " Reference inside a method - " + className + "::" + methodName);
+            }
+            nextReference = null;
+            break;
+         default:
+            System.out.println("unexpected reference " + point);
+      }
+      return nextReference;
+   }
+
+   /**
+    * This method tags the JVM and return an index. You can navigate through
+    * references using this returned HashMap. This method can't be exposed
+    * through JMX as it would serialize a huge amount of data.
+    * 
+    * @return HashMap<Long objectId,ArrayList<ReferenceDataPoint> referencees>
+    * */
+   public Map<Long, List<ReferenceDataPoint>> createIndexMatrix() throws IOException
+   {
+      releaseTags();
+      final HashMap<Long, List<ReferenceDataPoint>> referencesMap = new HashMap<Long, List<ReferenceDataPoint>>();
+      File tmpFile = File.createTempFile("tmpRefs", ".tmp");
+      notifyOnReferences(tmpFile.getAbsolutePath(), new JVMTICallBack()
+      {
+         int count = 0;
+
+         public void notifyReference(final long referenceHolder,
+                                     final long referencedObject,
+                                     final long classTag,
+                                     final long index,
+                                     final long method,
+                                     final byte referenceType)
+         {
+            if (count == 0)
+            {
+               System.out.println("started receiving references");
+            }
+            count++;
+            if (count % 1000 == 0)
+            {
+               System.out.println(count + " references received");
+            }
+            ReferenceDataPoint dataPoint = new ReferenceDataPoint(referenceHolder,
+                                                                  referencedObject,
+                                                                  classTag,
+                                                                  index,
+                                                                  method,
+                                                                  referenceType);
+            Long indexLong = new Long(referencedObject);
+            List<ReferenceDataPoint> arrayList = (ArrayList<ReferenceDataPoint>)referencesMap.get(indexLong);
+            if (arrayList == null)
+            {
+               arrayList = new ArrayList<ReferenceDataPoint>();
+               referencesMap.put(indexLong, arrayList);
+            }
+            arrayList.add(dataPoint);
+         }
+
+         public void notifyClass(final long classTag, final Class clazz)
+         {
+         }
+
+         public void notifyObject(final long classTag, final long objectId, final long bytes)
+         {
+         }
+      });
+
+      tmpFile.delete();
+
+      return referencesMap;
+   }
+
+   /**
+    * Show the reference holders tree of an object
+    * 
+    * @param className
+    *            The name of the class to explore
+    * @param maxLevel
+    *            The number of levels to explode. Be careful as if you put this
+    *            number too high, you migh endup in a forever loop, specially
+    *            if your object is referencing something too generic
+    * @param solveReferencesOnClass
+    *            Will expose the tree on the class
+    * @param solveReferencesOnClassLoader
+    *            Will expode the tree on the classLoader (I mostly recommend to
+    *            only look for classLoader's references)
+    * @param useToString
+    *            If true, will use toString when an object is printed. If False
+    *            will use className@<System.identityHashCode(object)>
+    * @param weakAndSoft
+    *            If false, won't detail references on Weak and Soft References
+    * @param printObject
+    *            If true, Will print (with toString) every single instance of
+    *            the object passed as parameter
+    */
+   public String exploreClassReferences(final String className,
+                                        final int maxLevel,
+                                        final boolean solveReferencesOnClasses,
+                                        final boolean solveReferencesOnClassLoaders,
+                                        final boolean useToString,
+                                        final boolean weakAndSoft,
+                                        final boolean printObjects)
+   {
+      forceGC();
+      if (!solveReferencesOnClasses && !solveReferencesOnClassLoaders && !printObjects)
+      {
+         return "<b> you have to select at least solveReferences || solveClassLoaders || printObjects </b>";
+      }
+
+      Map referencesMap = null;
+      try
+      {
+         referencesMap = createIndexMatrix();
+      }
+      catch (Exception e)
+      {
+         CharArrayWriter charArray = new CharArrayWriter();
+         PrintWriter out = new PrintWriter(charArray);
+         e.printStackTrace(out);
+         return charArray.toString();
+      }
+
+      try
+      {
+         CharArrayWriter charArray = new CharArrayWriter();
+         PrintWriter out = new PrintWriter(charArray);
+
+         out.println(exploreClassReferences(className,
+                                            maxLevel,
+                                            solveReferencesOnClasses,
+                                            solveReferencesOnClassLoaders,
+                                            useToString,
+                                            weakAndSoft,
+                                            referencesMap));
+
+         if (printObjects)
+         {
+            releaseTags();
+            Class classes[] = getLoadedClasses();
+
+            for (Class clazz : classes)
+            {
+               if (clazz.getName().equals(className))
+               {
+                  Object[] objs = this.getAllObjects(clazz);
+
+                  if (objs.length != 0)
+                  {
+                     out.println("<br> Instances of:" + clazz.getName() + " ClassLoader=" + clazz.getClassLoader());
+                     for (int countOBJ = 0; countOBJ < objs.length; countOBJ++)
+                     {
+                        out.println("<br>" + clazz.getName() + "[" + countOBJ + "]=" + objs[countOBJ]);
+                     }
+                  }
+               }
+            }
+         }
+
+         out.flush();
+
+         return charArray.toString();
+      }
+      finally
+      {
+         referencesMap.clear();
+         releaseTags();
+      }
+   }
+
+   /**
+    * This is an overload to reuse the matrix index in case you already have
+    * indexed the JVM
+    */
+   public String exploreClassReferences(final String className,
+                                        final int maxLevel,
+                                        final boolean solveReferencesOnClasses,
+                                        final boolean solveReferencesOnClassLoaders,
+                                        final boolean useToString,
+                                        final boolean weakAndSoft,
+                                        final Map referencesMap)
+   {
+      CharArrayWriter charArray = new CharArrayWriter();
+      PrintWriter out = new PrintWriter(charArray);
+
+      try
+      {
+
+         Class[] loadClasses = getLoadedClasses();
+
+         for (Class loadClasse : loadClasses)
+         {
+            if (loadClasse.getName().equals(className))
+            {
+               out.println("<br><br><br><b>References to " + loadClasse + "</b>");
+               if (solveReferencesOnClasses)
+               {
+                  exploreObject(out, loadClasse, 0, maxLevel, useToString, weakAndSoft, referencesMap, new HashSet());
+               }
+               if (solveReferencesOnClassLoaders)
+               {
+                  if (loadClasse.getClassLoader() != null)
+                  {
+                     out.println("<br><b><i>references to its classloader " + loadClasse.getClassLoader() + "</i></b>");
+                     exploreObject(out,
+                                   loadClasse.getClassLoader(),
+                                   0,
+                                   maxLevel,
+                                   useToString,
+                                   weakAndSoft,
+                                   referencesMap,
+                                   new HashSet());
+                  }
+               }
+               out.println("<br>");
+
+            }
+         }
+
+         loadClasses = null;
+
+         return charArray.toString();
+      }
+      catch (Exception e)
+      {
+         charArray = new CharArrayWriter();
+         out = new PrintWriter(charArray);
+         e.printStackTrace(out);
+         return charArray.toString();
+      }
+   }
+
+   /**
+    * Show the reference holders tree of an object. This method is also exposed
+    * through MBean.
+    */
+   public String exploreObjectReferences(final String className, final int maxLevel, final boolean useToString)
+   {
+      forceGC();
+
+      Object obj[] = this.getAllObjects(className);
+
+      System.out.println("Obj.length = " + obj.length);
+
+      Map referencesMap = null;
+      try
+      {
+         referencesMap = createIndexMatrix();
+      }
+      catch (Exception e)
+      {
+         CharArrayWriter charArray = new CharArrayWriter();
+         PrintWriter out = new PrintWriter(charArray);
+         e.printStackTrace(out);
+         return charArray.toString();
+      }
+
+      CharArrayWriter charArray = new CharArrayWriter();
+      PrintWriter out = new PrintWriter(charArray);
+
+      try
+      {
+         for (int i = 0; i < Math.min(50, obj.length); i++)
+         {
+            out.println("<br><b>References to obj[" + i +
+                        "]=" +
+                        (useToString ? obj[i].toString() : obj[i].getClass().getName()));
+            out.println(exploreObjectReferences(referencesMap, obj[i], maxLevel, useToString));
+         }
+         return charArray.toString();
+      }
+      finally
+      {
+         referencesMap.clear();
+         releaseTags();
+      }
+   }
+
+   /**
+    * Show the reference holders tree of an object. This returns a report you
+    * can visualize through MBean.
+    */
+   public String exploreObjectReferences(final Map referencesMap,
+                                         final Object thatObject,
+                                         final int maxLevel,
+                                         final boolean useToString)
+   {
+      CharArrayWriter charArray = new CharArrayWriter();
+      PrintWriter out = new PrintWriter(charArray);
+
+      try
+      {
+         exploreObject(out, thatObject, 0, maxLevel, useToString, false, referencesMap, new HashSet());
+         out.println("<br>");
+         return charArray.toString();
+      }
+      catch (Exception e)
+      {
+         charArray = new CharArrayWriter();
+         out = new PrintWriter(charArray);
+         e.printStackTrace(out);
+         return charArray.toString();
+      }
+   }
+
+   /**
+    * Forces an OutOfMemoryError and releases the memory immediatly. This will
+    * force SoftReferences to go away.
+    */
+   public void forceReleaseOnSoftReferences()
+   {
+      SoftReference reference = new SoftReference(new Object());
+
+      ArrayList list = new ArrayList();
+      int i = 0;
+      try
+      {
+         while (true)
+         {
+            list.add("A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String " + i++);
+            if (i % 1000 == 0) // doing the check on each 100 elements
+            {
+               if (reference.get() == null)
+               {
+                  System.out.println("Break as the soft reference was gone");
+                  break;
+               }
+            }
+         }
+      }
+      catch (Throwable e)
+      {
+      }
+
+      list.clear();
+      try
+      {
+         ByteArrayOutputStream byteout = new ByteArrayOutputStream();
+         ObjectOutputStream out = new ObjectOutputStream(byteout);
+
+         out.writeObject(new Dummy());
+
+         ByteArrayInputStream byteInput = new ByteArrayInputStream(byteout.toByteArray());
+         ObjectInputStream input = new ObjectInputStream(byteInput);
+         input.readObject();
+
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+
+      forceGC();
+   }
+
+   /**
+    * Used just to serialize anything and release SoftCache on java
+    * Serialization
+    */
+   static class Dummy implements Serializable
+   {
+      private static final long serialVersionUID = 1L;
+   }
+
+   public void startMemoryProfiler(final InetSocketAddress address, final CountDownLatch latchRunning) throws Exception
+   {
+      System.out.println("JBoss Memory Profiler running on " + address);
+      MemoryProfilerEmbedded profilerServer = new MemoryProfilerEmbedded(address, latchRunning, this);
+      profilerServer.start();
+   }
+
+   public void startMemoryProfiler(final InetSocketAddress address) throws Exception
+   {
+      CountDownLatch latchRunning = new CountDownLatch(1);
+      startMemoryProfiler(address, latchRunning);
+      latchRunning.await();
+   }
+
+   /**
+    * Will show a report of every class loaded on this JVM. At the beggining of
+    * the report you will see duplicated classes (classes loaded in more than
+    * one classLoader)
+    */
+   public String listClassesHTMLReport() throws Exception
+   {
+      try
+      {
+         forceGC();
+         CharArrayWriter charArray = new CharArrayWriter();
+         PrintWriter out = new PrintWriter(charArray);
+
+         Collection classSet = createTreeSet(new ClassSorterByClassName());
+
+         boolean printedHeader = false;
+
+         ClassLoader systemClassLoaderDummy = new ClassLoader()
+         {
+            public String toString()
+            {
+               return "SystemClassLoader";
+            }
+         };
+         ArrayList classLoaderDuplicates = new ArrayList();
+         Iterator iter = classSet.iterator();
+         String currentName = null;
+         Class currentClass = null;
+         while (iter.hasNext())
+         {
+            currentClass = (Class)iter.next();
+            if (currentName != currentClass.getName())
+            {
+               if (classLoaderDuplicates.size() > 1)
+               {
+                  if (!printedHeader)
+                  {
+                     out.println("<br><b>List of duplicated classes</b>");
+                     printedHeader = true;
+                  }
+
+                  out.println("<br>" + "<b> Class " + currentName + " was loaded on these classLoaders:</b>");
+                  Iterator iterClassLoader = classLoaderDuplicates.iterator();
+                  while (iterClassLoader.hasNext())
+                  {
+                     ClassLoader loader = (ClassLoader)iterClassLoader.next();
+                     out.println("<br>" + loader.toString());
+                  }
+
+               }
+               currentName = currentClass.getName();
+               classLoaderDuplicates.clear();
+            }
+
+            ClassLoader loader = currentClass.getClassLoader();
+            if (loader == null)
+            {
+               loader = systemClassLoaderDummy;
+            }
+            classLoaderDuplicates.add(loader);
+
+            currentName = currentClass.getName();
+         }
+
+         if (classLoaderDuplicates.size() > 1)
+         {
+            out.println("<br>" + "<b> Class " + currentName + " was loaded on these classLoaders:</b>");
+            Iterator iterClassLoader = classLoaderDuplicates.iterator();
+            while (iterClassLoader.hasNext())
+            {
+               ClassLoader loader = (ClassLoader)iterClassLoader.next();
+               out.println("<br>" + loader.toString());
+            }
+
+         }
+
+         out.println("<br><b>List of classes by ClassLoader</b>");
+         classSet = retrieveLoadedClassesByClassLoader();
+
+         // I will need a dummy reference, as the first classLoader on the
+         // iterator will be null
+         ClassLoader currentClassLoader = new ClassLoader()
+         {
+         };
+         out.println("<br>");
+
+         iter = classSet.iterator();
+         while (iter.hasNext())
+         {
+            Class clazz = (Class)iter.next();
+            if (currentClassLoader != clazz.getClassLoader())
+            {
+               currentClassLoader = clazz.getClassLoader();
+               out.println("<br><b>ClassLoader = " + (currentClassLoader == null ? "System Class Loader"
+                                                                                : currentClassLoader.toString()) +
+                           "</b>");
+            }
+            out.println("Class = " + clazz.getName());
+         }
+
+         return new String(charArray.toCharArray());
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+
+   /** Used by JSPs and JMX to report */
+   public Collection retrieveLoadedClassesByClassName()
+   {
+      Collection classSet;
+      classSet = createTreeSet(new ClassSorterByClassName());
+      return classSet;
+   }
+
+   /** Used by JSPs and JMX to report */
+   public Collection retrieveLoadedClassesByClassLoader()
+   {
+      Collection classSet;
+      classSet = createTreeSet(new ClassSorterByClassLoader());
+      return classSet;
+   }
+
+   private Collection createTreeSet(final Comparator comparator)
+   {
+      Class[] classes = getLoadedClasses();
+
+      ArrayList classSet = new ArrayList();
+
+      for (Class classe : classes)
+      {
+         classSet.add(classe);
+      }
+
+      Collections.sort(classSet, comparator);
+      return classSet;
+   }
+
+   static class InnerCallBack implements JVMTICallBack
+   {
+
+      HashMap<Long, Class<?>> classesMap = new HashMap<Long, Class<?>>();
+
+      WeakHashMap<Class<?>, InventoryDataPoint> maps = new WeakHashMap<Class<?>, InventoryDataPoint>();
+
+      public void notifyClass(final long classTag, final Class<?> clazz)
+      {
+         classesMap.put(classTag, clazz);
+      }
+
+      public void notifyObject(final long classTag, final long objectId, final long bytes)
+      {
+         Class<?> clazz = (Class<?>)classesMap.get(classTag);
+
+         if (clazz != null) // this is not supposed to happen, but just in
+         // case I keep this if here
+         {
+            InventoryDataPoint point = (InventoryDataPoint)maps.get(clazz);
+            if (point == null)
+            {
+               point = new InventoryDataPoint(clazz);
+               maps.put(clazz, point);
+            }
+
+            point.bytes += bytes;
+            point.instances++;
+         }
+
+      }
+
+      public void notifyReference(final long referenceHolder,
+                                  final long referencedObject,
+                                  final long classTag,
+                                  final long index,
+                                  final long method,
+                                  final byte referenceType)
+      {
+      }
+
+   }
+
+   /**
+    * It will return true if the comparisson didn't represent any changes. This
+    * can be used by JUnitTests to validate the consumption of the memory is on
+    * the expected results.
+    * 
+    * @param reportOutput
+    *            You could set System.out here. The location where logging
+    *            information is going to be sent.
+    * @param map1
+    *            The first snapshot.
+    * @param map2
+    *            The second snapshot.
+    * @param ignoredClasses
+    *            Classes you want to ignore on the comparisson. Used to ignore
+    *            things you know are going to be produced and you don't have
+    *            control over the testcase.
+    * @param prefixesToIgnore
+    *            Same thing as classes, but every classes starting with these
+    *            prefixes are going to be ignored.
+    * @param expectedIncreases
+    *            An array of InventoryDataPoint with the maximum number of
+    *            instances each class could be generating.
+    * @return true if the assertion is okay
+    */
+   public boolean compareInventories(final PrintStream reportOutput,
+                                     final Map map1,
+                                     final Map map2,
+                                     final Class[] ignoredClasses,
+                                     final String[] prefixesToIgnore,
+                                     final InventoryDataPoint[] expectedIncreases)
+   {
+      HashSet ignoredItems = new HashSet();
+      if (ignoredClasses != null)
+      {
+         for (Class ignoredClasse : ignoredClasses)
+         {
+            ignoredItems.add(ignoredClasse);
+         }
+      }
+
+      HashMap expectedIncreasesHash = new HashMap();
+      if (expectedIncreases != null)
+      {
+         for (InventoryDataPoint expectedIncrease : expectedIncreases)
+         {
+            Class clazz = expectedIncrease.getClazz();
+            expectedIncreasesHash.put(clazz, expectedIncrease);
+         }
+      }
+
+      // expected increase based on map1's size
+      addExpectedIncrease(expectedIncreasesHash, "java.lang.ref.ReferenceQueue$Lock", 1);
+      addExpectedIncrease(expectedIncreasesHash, "java.util.WeakHashMap", 1);
+      addExpectedIncrease(expectedIncreasesHash, "java.lang.ref.ReferenceQueue", 1);
+      addExpectedIncrease(expectedIncreasesHash, "[Ljava.util.WeakHashMap$Entry;", 1);
+      addExpectedIncrease(expectedIncreasesHash, "java.lang.ref.WeakReference", map1.size());
+      addExpectedIncrease(expectedIncreasesHash, "java.util.WeakHashMap$Entry", map1.size());
+
+      boolean reportOK = true;
+
+      Iterator iterMap1 = map1.entrySet().iterator();
+      while (iterMap1.hasNext())
+      {
+         Map.Entry entry = (Map.Entry)iterMap1.next();
+         Class clazz = (Class)entry.getKey();
+
+         boolean isIgnoredPrefix = false;
+         if (prefixesToIgnore != null)
+         {
+            for (String element : prefixesToIgnore)
+            {
+               if (clazz.getName().startsWith(element))
+               {
+                  isIgnoredPrefix = true;
+                  break;
+               }
+            }
+         }
+         if (!isIgnoredPrefix && !ignoredItems.contains(entry.getKey()))
+         {
+            InventoryDataPoint point1 = (InventoryDataPoint)entry.getValue();
+            InventoryDataPoint point2 = (InventoryDataPoint)map2.get(clazz);
+            if (point2 != null)
+            {
+               if (point2.getInstances() > point1.getInstances())
+               {
+                  InventoryDataPoint expectedIncrease = (InventoryDataPoint)expectedIncreasesHash.get(clazz);
+                  boolean failed = true;
+                  if (expectedIncrease != null)
+                  {
+                     if (point2.getInstances() - point1.getInstances() <= expectedIncrease.getInstances())
+                     {
+                        failed = false;
+                     }
+                  }
+                  if (failed)
+                  {
+                     int expected = 0;
+                     if (expectedIncrease != null)
+                     {
+                        expected = expectedIncrease.getInstances();
+                     }
+                     reportOK = false;
+                     reportOutput.println("<br> Class " + clazz.getName() +
+                                          " had an increase of " +
+                                          (point2.getInstances() - point1.getInstances() - expected) +
+                                          " instances represented by " +
+                                          (point2.getBytes() - point1.getBytes()) +
+                                          " bytes");
+                     if (expectedIncrease != null)
+                     {
+                        reportOutput.print("<br> " + (point2.getInstances() - point1.getInstances() - expectedIncrease.getInstances()) +
+                                           " higher than expected");
+                     }
+
+                  }
+               }
+            }
+         }
+      }
+
+      return reportOK;
+   }
+
+   private void addExpectedIncrease(final HashMap expectedIncreasesHash, final String name, final int numberOfInstances)
+   {
+      Class tmpClass = getClassByName(name);
+      if (tmpClass != null)
+      {
+         expectedIncreasesHash.put(tmpClass, new InventoryDataPoint(tmpClass, numberOfInstances));
+      }
+   }
+
+   /**
+    * Returns a WeakHashMap<Class,InventoryDataPoint> summarizing the current
+    * JVM's inventory.
+    * */
+   public Map<Class<?>, InventoryDataPoint> produceInventory() throws IOException
+   {
+      forceGC();
+      InnerCallBack callBack = new InnerCallBack();
+      File tmpFileObjects = File.createTempFile("delete-me", ".objects");
+      try
+      {
+         notifyInventory(true, null, tmpFileObjects.getAbsolutePath(), callBack);
+      }
+      finally
+      {
+         if (tmpFileObjects.exists())
+         {
+            try
+            {
+               tmpFileObjects.delete();
+            }
+            catch (Exception ignored)
+            {
+            }
+         }
+      }
+
+      return callBack.maps;
+   }
+
+   public String inventoryReport() throws Exception
+   {
+      return inventoryReport(true);
+   }
+
+   /** Will list the current memory inventory. Exposed through JMX. */
+   public String inventoryReport(final boolean html) throws Exception
+   {
+      Map map = produceInventory();
+
+      TreeSet valuesSet = new TreeSet(map.values());
+      Iterator iterDataPoints = valuesSet.iterator();
+      CharArrayWriter charArray = new CharArrayWriter();
+      PrintWriter out = new PrintWriter(charArray);
+
+      if (html)
+      {
+         out.println("<table><tr><td>Class</td><td>#Instances</td><td>#Bytes</td></tr>");
+      }
+      else
+      {
+         out.println(String.format("|%1$-100s|%2$10s|%3$10s|", "Class", "Instances", "Bytes"));
+      }
+
+      while (iterDataPoints.hasNext())
+      {
+         InventoryDataPoint point = (InventoryDataPoint)iterDataPoints.next();
+         if (html)
+         {
+            out.println("<tr><td>" + point.getClazz().getName() +
+                        "</td><td>" +
+                        point.getInstances() +
+                        "</td><td>" +
+                        point.getBytes() +
+                        "</td></tr>");
+         }
+         else
+         {
+            out.println(String.format("|%1$-100s|%2$10d|%3$10d|",
+                                      point.getClazz().getName(),
+                                      point.getInstances(),
+                                      point.getBytes()));
+         }
+      }
+
+      if (html)
+      {
+         out.println("</table>");
+      }
+
+      return charArray.toString();
+   }
+
+   /**
+    * Will print a report of every instance of the class passed by parameter.
+    * Exposed through JMX .
+    */
+   public String printObjects(final String className) throws Exception
+   {
+      CharArrayWriter charArray = new CharArrayWriter();
+      PrintWriter out = new PrintWriter(charArray);
+
+      Object objects[] = this.getAllObjects(className);
+
+      out.println("<table>");
+      for (Object object : objects)
+      {
+         out.println("<tr><td>");
+         out.println(object);
+         if (object instanceof Object[])
+         {
+            out.println("</td><td>");
+            out.println("array of " + ((Object[])object).length);
+            out.println("</td></tr>");
+         }
+      }
+
+      out.println("</table>");
+
+      return charArray.toString();
+   }
+
+}

Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTITypes.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTITypes.java	                        (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTITypes.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti;
+
+/**
+ * A JVMTITypes
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class JVMTITypes
+{
+
+   public static String toString(final int referenceType)
+   {
+      switch (referenceType)
+      {
+         case JVMTI_REFERENCE_INSTANCE:
+            return "JVMTI_REFERENCE_CLASS";
+
+         case JVMTI_REFERENCE_FIELD:
+            return "JVMTI_REFERENCE_FIELD";
+         case JVMTI_REFERENCE_ARRAY_ELEMENT:
+            return "JVMTI_REFERENCE_ARRAY_ELEMENT";
+
+         case JVMTI_REFERENCE_CLASS_LOADER:
+            return "JVMTI_REFERENCE_CLASS_LOADER";
+
+         case JVMTI_REFERENCE_SIGNERS:
+            return "JVMTI_REFERENCE_SIGNERS";
+
+         case JVMTI_REFERENCE_PROTECTION_DOMAIN:
+            return "JVMTI_REFERENCE_PROTECTION_DOMAIN";
+
+         case JVMTI_REFERENCE_INTERFACE:
+            return "JVMTI_REFERENCE_INTERFACE";
+
+         case JVMTI_REFERENCE_STATIC_FIELD:
+            return "JVMTI_REFERENCE_STATIC_FIELD";
+
+         case JVMTI_REFERENCE_CONSTANT_POOL:
+            return "JVMTI_REFERENCE_CONSTANT_POOL";
+
+         case ROOT_REFERENCE:
+            return "ROOT_REFERENCE";
+
+         case THREAD_REFERENCE:
+            return "THREAD_REFERENCE";
+
+         default:
+            return "UnknownReferenceType(" + referenceType + ")";
+
+      }
+   }
+
+   // Constants -----------------------------------------------------
+   public static final int JVMTI_REFERENCE_INSTANCE = 1;// Reference from an object to its class.
+
+   public static final int JVMTI_REFERENCE_FIELD = 2;// Reference from an object to the value of one of its instance
+
+   // fields. For references of this kind the referrer_index parameter
+   // to the jvmtiObjectReferenceCallback is the index of the the
+   // instance field. The index is based on the order of all the
+   // object's fields. This includes all fields of the directly
+   // declared static and instance fields in the class, and includes
+   // all fields (both public and private) fields declared in
+   // superclasses and superinterfaces. The index is thus calculated
+   // by summing the index of field in the directly declared class
+   // (see GetClassFields), with the total number of fields (both
+   // public and private) declared in all superclasses and
+   // superinterfaces. The index starts at zero.
+
+   public static final int JVMTI_REFERENCE_ARRAY_ELEMENT = 3;// Reference from an array to one of its elements. For
+
+   // references of this kind the referrer_index parameter to
+   // the jvmtiObjectReferenceCallback is the array index.
+
+   public static final int JVMTI_REFERENCE_CLASS_LOADER = 4;// Reference from a class to its class loader.
+
+   public static final int JVMTI_REFERENCE_SIGNERS = 5;// Reference from a class to its signers array.
+
+   public static final int JVMTI_REFERENCE_PROTECTION_DOMAIN = 6;// Reference from a class to its protection domain.
+
+   public static final int JVMTI_REFERENCE_INTERFACE = 7;// Reference from a class to one of its interfaces.
+
+   public static final int JVMTI_REFERENCE_STATIC_FIELD = 8;// Reference from a class to the value of one of its static
+
+   // fields. For references of this kind the referrer_index
+   // parameter to the jvmtiObjectReferenceCallback is the
+   // index of the static field. The index is based on the
+   // order of the directly declared static and instance fields
+   // in the class (not inherited fields), starting at zero.
+   // See GetClassFields.
+
+   public static final int JVMTI_REFERENCE_CONSTANT_POOL = 9;// Reference from a class to a resolved entry in the
+
+   // constant pool. For references of this kind the
+   // referrer_index parameter to the
+   // jvmtiObjectReferenceCallback is the index into constant
+   // pool table of the class, starting at 1. See The Constant
+   // Pool in the Java Virtual Machine Specification.
+
+   public static final int ROOT_REFERENCE = 10;
+
+   public static final int THREAD_REFERENCE = 11;
+
+}

Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/ReferenceDataPoint.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/ReferenceDataPoint.java	                        (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/ReferenceDataPoint.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,132 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.profiler.jvmti;
+
+public class ReferenceDataPoint
+{
+   public ReferenceDataPoint(final long referenceHolder,
+                             final long referencedObject,
+                             final long classTag,
+                             final long index,
+                             final long method,
+                             final byte referenceType)
+   {
+      this.referenceHolder = referenceHolder;
+      this.referencedObject = referencedObject;
+      this.classTag = classTag;
+      this.index = index;
+      this.method = method;
+      this.referenceType = referenceType;
+   }
+
+   private long referenceHolder;
+
+   private long referencedObject;
+
+   private long classTag;
+
+   private long index;
+
+   private long method;
+
+   private byte referenceType;
+
+   public long getIndex()
+   {
+      return index;
+   }
+
+   public void setIndex(final long index)
+   {
+      this.index = index;
+   }
+
+   public long getMethod()
+   {
+      return method;
+   }
+
+   public void setMethod(final long method)
+   {
+      this.method = method;
+   }
+
+   public long getReferencedObject()
+   {
+      return referencedObject;
+   }
+
+   public void setReferencedObject(final long referencedObject)
+   {
+      this.referencedObject = referencedObject;
+   }
+
+   public long getReferenceHolder()
+   {
+      return referenceHolder;
+   }
+
+   public void setReferenceHolder(final long referenceHolder)
+   {
+      this.referenceHolder = referenceHolder;
+   }
+
+   public byte getReferenceType()
+   {
+      return referenceType;
+   }
+
+   public void setReferenceType(final byte referenceType)
+   {
+      this.referenceType = referenceType;
+   }
+
+   public long getClassTag()
+   {
+      return classTag;
+   }
+
+   public void setClassTag(final long classTag)
+   {
+      this.classTag = classTag;
+   }
+
+   @Override
+   public String toString()
+   {
+      return super.toString() + " {referenceHolder=" +
+             referenceHolder +
+             "\n   referencedObject=" +
+             referencedObject +
+             "\n   classTag=" +
+             classTag +
+             "\n   index=" +
+             index +
+             "\n   method=" +
+             method +
+             "\n   referenceType=" +
+             referenceType +
+             "}";
+   }
+
+}

Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java	                        (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+
+/**
+ * A AbstractHandler
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public abstract class AbstractHandler implements HttpHandler
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   protected final MemoryProfilerEmbedded server;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   /**
+    * @param server
+    */
+   public AbstractHandler(final MemoryProfilerEmbedded server)
+   {
+      super();
+      this.server = server;
+   }
+
+   /* (non-Javadoc)
+    * @see com.sun.net.httpserver.HttpHandler#handle(com.sun.net.httpserver.HttpExchange)
+    */
+   public void handle(final HttpExchange exchange) throws IOException
+   {
+      exchange.getRequestBody().close();
+      PrintStream output = new PrintStream(exchange.getResponseBody());
+      try
+      {
+         exchange.sendResponseHeaders(200, 0);
+         output.println("<html><body>");
+         output.println("<a href='./'>Main Page</a><br/>");
+         output.println("<a href='./stop'>Stop</a><br/>");
+         output.println("<br/>");
+         handle(exchange, parseURI(exchange.getRequestURI()), output);
+         output.println("</body></html>");
+         output.close();
+      }
+      catch (Throwable e)
+      {
+         e.printStackTrace();
+         output.println("Error: " + e.getMessage());
+         output.close();
+      }
+   }
+
+   public abstract void handle(HttpExchange exchange, Map<String, String> queryAttributes, PrintStream output) throws Exception;
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   protected Map<String, String> parseURI(final URI uri)
+   {
+
+      HashMap<String, String> map = new HashMap<String, String>();
+
+      if (uri.getQuery() != null)
+      {
+
+         StringTokenizer tokens = new StringTokenizer(uri.getQuery(), "&");
+
+         while (tokens.hasMoreTokens())
+         {
+            String str = tokens.nextToken();
+
+            StringTokenizer tokenEqual = new StringTokenizer(str, "=");
+
+            String key = tokenEqual.nextToken();
+            String value = tokenEqual.nextToken();
+
+            map.put(key, value);
+         }
+      }
+
+      return map;
+   }
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java	                        (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import com.sun.net.httpserver.HttpExchange;
+
+import org.jboss.profiler.jvmti.JVMTIInterface;
+import org.jboss.profiler.jvmti.JVMTITypes;
+import org.jboss.profiler.jvmti.ReferenceDataPoint;
+
+/**
+ * A InstancesHandler
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class InstancesHandler extends AbstractHandler
+{
+
+   // Constants -----------------------------------------------------
+
+   private static final int NUMBER_OF_ELEMENTS = 300;
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+   /**
+    * @param server
+    */
+   public InstancesHandler(final MemoryProfilerEmbedded server)
+   {
+      super(server);
+   }
+
+   // Public --------------------------------------------------------
+
+   /* (non-Javadoc)
+    * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map, java.io.PrintStream)
+    */
+   @Override
+   public synchronized void handle(final HttpExchange exchange,
+                                   final Map<String, String> queryAttributes,
+                                   final PrintStream output) throws Exception
+   {
+      JVMTIInterface jvmti = server.getJvmti();
+      String classToPrint = queryAttributes.get("class");
+      String elementStr = queryAttributes.get("element");
+
+      if (elementStr == null)
+      {
+         elementStr = "0";
+      }
+
+      int elementNR = Integer.parseInt(elementStr);
+
+      output.println("<a href='./instances?class=" + classToPrint +
+                     "&element=" +
+                     (elementNR + NUMBER_OF_ELEMENTS) +
+                     "'>NEXT</a>");
+      if (elementNR > 0)
+      {
+         output.println("<a href='./instances?class=" + classToPrint +
+                        "&element=" +
+                        (elementNR - NUMBER_OF_ELEMENTS) +
+                        "'>PREVIOUS</a>");
+      }
+
+      output.println("<br/>");
+      output.println("<br/>");
+
+      Map<Long, List<ReferenceDataPoint>> index = server.getIndex();
+      if (index == null)
+      {
+         index = server.createIndex();
+      }
+
+      Class clazz = jvmti.getClassByName(classToPrint);
+
+      if (clazz == null)
+      {
+         output.println("No Objects");
+      }
+
+      long objID = jvmti.getTagOnObject(clazz);
+
+      List<ReferenceDataPoint> references = index.get(objID);
+
+      if (references == null || references.size() == 0)
+      {
+         output.println("No Objects for " + classToPrint);
+         return;
+      }
+
+      ArrayList<Long> objs = new ArrayList<Long>();
+
+      int elementFound = 0;
+      for (ReferenceDataPoint point : references)
+      {
+         if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_INSTANCE)
+         {
+            if (elementFound++ > elementNR)
+            {
+               if (point.getReferenceHolder() != 0)
+               {
+                  objs.add(point.getReferenceHolder());
+               }
+            }
+
+            if (objs.size() > NUMBER_OF_ELEMENTS)
+            {
+               break;
+            }
+         }
+      }
+
+      for (Long objReferencedID : objs)
+      {
+         Object referenced = jvmti.getObjectOnTag(objReferencedID);
+         String strName;
+         if (referenced == null)
+         {
+            strName = "Null";
+         }
+         else
+         {
+            strName = referenced.toString();
+         }
+
+         output.println("<a href='./reference?obj0=" + objReferencedID + "'>" + strName + "</a><br/>");
+      }
+
+   }
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/MemoryProfilerEmbedded.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/MemoryProfilerEmbedded.java	                        (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/MemoryProfilerEmbedded.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+
+import com.sun.net.httpserver.HttpServer;
+
+import org.jboss.profiler.jvmti.JVMTIInterface;
+import org.jboss.profiler.jvmti.ReferenceDataPoint;
+
+/**
+ * A MemoryProfilerEmbedded
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class MemoryProfilerEmbedded
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private HttpServer server;
+
+   private final CountDownLatch running;
+
+   private final InetSocketAddress address;
+
+   private final JVMTIInterface jvmti;
+
+   private Map<Long, List<ReferenceDataPoint>> index;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   /**
+    * @param running
+    */
+   public MemoryProfilerEmbedded(final InetSocketAddress address,
+                                 final CountDownLatch running,
+                                 final JVMTIInterface jvmti)
+   {
+      super();
+      this.running = running;
+      this.address = address;
+      this.jvmti = jvmti;
+   }
+
+   // Public --------------------------------------------------------
+
+   public void start() throws Exception
+   {
+
+      server = HttpServer.create(address, 0);
+
+      server.createContext("/", new RootHandler(this));
+      server.createContext("/instances", new InstancesHandler(this));
+      server.createContext("/reference", new ReferenceHandler(this));
+      server.createContext("/stop", new StopHandler(this));
+
+      server.start();
+   }
+
+   /**
+    * @return the running
+    */
+   public CountDownLatch getRunning()
+   {
+      return running;
+   }
+
+   /**
+    * @return the address
+    */
+   public InetSocketAddress getAddress()
+   {
+      return address;
+   }
+
+   /**
+    * @return the jvmti
+    */
+   public JVMTIInterface getJvmti()
+   {
+      return jvmti;
+   }
+
+   public void clearIndex()
+   {
+      jvmti.releaseTags();
+      if (index != null)
+      {
+         index.clear();
+      }
+      index = null;
+   }
+
+   public Map<Long, List<ReferenceDataPoint>> createIndex() throws Exception
+   {
+      clearIndex();
+
+      index = jvmti.createIndexMatrix();
+
+      return index;
+   }
+
+   public Map<Long, List<ReferenceDataPoint>> getIndex() throws Exception
+   {
+      return index;
+   }
+
+   /**
+    * 
+    */
+   public void stop() throws Exception
+   {
+      new Thread()
+      {
+         @Override
+         public void run()
+         {
+
+            server.stop(0);
+            running.countDown();
+            server = null;
+         }
+      }.start();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java	                        (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,210 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+import java.util.List;
+import java.util.Map;
+
+import com.sun.net.httpserver.HttpExchange;
+
+import org.jboss.profiler.jvmti.JVMTIInterface;
+import org.jboss.profiler.jvmti.JVMTITypes;
+import org.jboss.profiler.jvmti.ReferenceDataPoint;
+
+/**
+ * A ReferenceHandler
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class ReferenceHandler extends AbstractHandler
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+   /**
+    * @param server
+    */
+   public ReferenceHandler(final MemoryProfilerEmbedded server)
+   {
+      super(server);
+   }
+
+   // Public --------------------------------------------------------
+
+   /* (non-Javadoc)
+    * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map, java.io.PrintStream)
+    */
+   @Override
+   public synchronized void handle(final HttpExchange exchange,
+                                   final Map<String, String> queryAttributes,
+                                   final PrintStream output) throws Exception
+   {
+
+      String query = exchange.getRequestURI().getRawQuery();
+
+      JVMTIInterface jvmti = server.getJvmti();
+
+      Map<Long, List<ReferenceDataPoint>> index = server.getIndex();
+
+      if (index == null)
+      {
+         index = server.createIndex();
+      }
+
+      int nparams = 0;
+
+      Object obj;
+      long objId = 0;
+
+      while (true)
+      {
+         if (queryAttributes.get("obj" + nparams) != null)
+         {
+            if (nparams > 0)
+            {
+               output.println(" -> ");
+            }
+            objId = Integer.parseInt(queryAttributes.get("obj" + nparams));
+            obj = jvmti.getObjectOnTag(objId);
+
+            String name = obj != null ? obj.toString() : "Null";
+
+            for (int i = 0; i < nparams; i++)
+            {
+               output.print("...");
+            }
+
+            output.print(name + "<br/>");
+            nparams++;
+         }
+         else
+         {
+            break;
+         }
+      }
+
+      List<ReferenceDataPoint> list = index.get(objId);
+
+      if (list == null || list.isEmpty())
+      {
+         output.println("Empty!");
+         return;
+      }
+
+      for (ReferenceDataPoint point : list)
+      {
+         String newURL = "./reference?" + query + "&obj" + nparams + "=" + point.getReferenceHolder();
+
+         Object referenceHolder = null;
+         if (point.getReferenceHolder() > 0)
+         {
+            referenceHolder = jvmti.getObjectOnTag(point.getReferenceHolder());
+         }
+
+         if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_FIELD)
+         {
+            Class<?> referenceClass = null;
+            Field referencedField = null;
+            if (referenceHolder != null)
+            {
+               referenceClass = referenceHolder.getClass();
+
+               referencedField = jvmti.getObjectField(referenceClass, (int)point.getIndex());
+            }
+
+            if (referencedField != null)
+            {
+               output.println("Field reference:" + referencedField.getDeclaringClass().getCanonicalName() +
+                              "::" +
+                              referencedField.getName() +
+
+                              "<a href='" +
+                              newURL +
+                              "'>(" +
+                              jvmti.convertToString(referenceHolder, true) +
+                              ")</a><br/>");
+            }
+            else
+            {
+               output.println("<a href='./reference?" + query +
+                              "&obj" +
+                              nparams +
+                              "=" +
+                              point.getReferenceHolder() +
+                              "'>Unkown Field reference</a><br/>");
+            }
+
+         }
+         else if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_ARRAY_ELEMENT)
+         {
+            if (referenceHolder == null)
+            {
+               output.println("Array reference (gone)</br>");
+            }
+            else
+            {
+               output.println("Array Refeference: <a href='" + newURL + "'>" + "array[" + point.getIndex() + "]</a><br/>");
+            }
+         }
+         else if (point.getReferenceType() == JVMTITypes.ROOT_REFERENCE)
+         {
+            output.println("ROOT</br>");
+         }
+         else if (point.getReferenceType() == JVMTITypes.THREAD_REFERENCE)
+         {
+
+            Class<?> methodClass = jvmti.getMethodClass(point.getMethod());
+            if (methodClass != null)
+            {
+               String className = null;
+               if (methodClass != null)
+               {
+                  className = methodClass.getName();
+               }
+
+               String methodName = jvmti.getMethodName(point.getMethod());
+               output.println("<br> Reference inside a method - " + className + "::" + methodName);
+            }
+         }
+
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java	                        (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import java.io.PrintStream;
+import java.net.URLEncoder;
+import java.util.Map;
+import java.util.TreeSet;
+
+import com.sun.net.httpserver.HttpExchange;
+
+import org.jboss.profiler.jvmti.InventoryDataPoint;
+
+/**
+ * A RootHandler
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class RootHandler extends AbstractHandler
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   /**
+    * @param server
+    */
+   public RootHandler(final MemoryProfilerEmbedded server)
+   {
+      super(server);
+   }
+
+   // Public --------------------------------------------------------
+
+   /* (non-Javadoc)
+    * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map)
+    */
+   @Override
+   public synchronized void handle(final HttpExchange exchange,
+                                   final Map<String, String> queryAttributes,
+                                   final PrintStream output) throws Exception
+   {
+      server.clearIndex();
+
+      Map<Class<?>, InventoryDataPoint> inventory = server.getJvmti().produceInventory();
+
+      TreeSet<InventoryDataPoint> points = new TreeSet<InventoryDataPoint>(inventory.values());
+
+      output.println("<table>");
+
+      output.println("<tr><td>Name</td><td>#Instances</td><td>#Bytes</td></tr>");
+
+      for (InventoryDataPoint point : points)
+      {
+         output.println("<tr><td><a href='./instances?class=" + URLEncoder.encode(point.getClazz().getName()) +
+                        "'>" +
+                        point.getClazz().getName() +
+                        "</a>" +
+                        "</td><td>" +
+                        point.getInstances() +
+                        "</td><td>" +
+                        point.getBytes() +
+                        "</td></tr>");
+      }
+
+      output.println("</table>");
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java	                        (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import java.io.PrintStream;
+import java.util.Map;
+
+import com.sun.net.httpserver.HttpExchange;
+
+/**
+ * A StopHandler
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class StopHandler extends AbstractHandler
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+   /**
+    * @param server
+    */
+   public StopHandler(final MemoryProfilerEmbedded server)
+   {
+      super(server);
+   }
+
+   // Public --------------------------------------------------------
+
+   /* (non-Javadoc)
+    * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map, java.io.PrintStream)
+    */
+   @Override
+   public void handle(final HttpExchange exchange, final Map<String, String> queryAttributes, final PrintStream output) throws Exception
+   {
+      output.println("Profiler stopped");
+      server.stop();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}


Property changes on: branches/JBossProfiler2/src/native
___________________________________________________________________
Name: svn:ignore
   - CMakeFiles
cmake_install.cmake
Makefile


   + CMakeFiles
cmake_install.cmake
Makefile
org_jboss_profiler_jvmti_JVMTIInterface.h


Modified: branches/JBossProfiler2/src/native/agent.cpp
===================================================================
--- branches/JBossProfiler2/src/native/agent.cpp	2009-06-24 15:17:45 UTC (rev 556)
+++ branches/JBossProfiler2/src/native/agent.cpp	2009-08-11 21:05:43 UTC (rev 557)
@@ -1,52 +1,1076 @@
-#include <iostream>
-#include <string>
 #include <stdlib.h>
 #include <stdio.h>
-#include <jni.h>
-#include <jvmti.h>
+#include <string.h>
+#include "jvmti.h"
 
+#include "org_jboss_profiler_jvmti_JVMTIInterface.h"
+
 #define AGENT_MAIN
-#include <agent.h>
+#include "agent.h"
 
-jint 
-init_jvmti_callbacks(JavaVM* jvm)
+jint initJVMTI(JavaVM *jvm)
 {
    jint res;
-   jvmtiError error;
-   jvmtiCapabilities capabilities;
-   jvmtiEventCallbacks callbacks;
 
-   res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_0);
-   if (res != JNI_OK) {
+   res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_0);   
+   if (res!=JNI_OK) {
       return res;
    }
+   
+   jvmtiError error;
 
-   // Set the capabilities
-   error = jvmti->GetCapabilities(&capabilities);
-   verifyError(error);
 
-   capabilities.can_generate_method_entry_events = 1;
+  jvmtiCapabilities   capabilities;
 
-   error = jvmti->AddCapabilities(&capabilities);
-   verifyError(error);
-   
-   jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks));
-   
+  error = jvmti->GetCapabilities(&capabilities);
+  verifyError(error);
+  capabilities.can_tag_objects = 1;
+  capabilities.can_generate_garbage_collection_events = 1;
+  capabilities.can_generate_method_entry_events = 1;
+  capabilities.can_generate_method_exit_events = 1;
+  error= jvmti->AddCapabilities(&capabilities);
+  verifyError(error);
+
    return JNI_OK;
 }
 
+JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved)
+{
+   return initJVMTI(jvm);
+}
 
 
-JNIEXPORT jint JNICALL 
-Agent_OnLoad(JavaVM *jvm, char *options, void *reserved)
+
+//#define DEBUG 0
+#include "org_jboss_profiler_jvmti_JVMTIInterface.h"
+
+/** Local function for dealing with memory heaps... loading objects */
+void memoryWriteReference(IterateControl* iterate, jlong tagReferrer, jlong tagReferee, jint index) 
 {
-   printf("Loading JBoss Profiler agent\n");
+#ifdef WINDOWS
+   fprintf (iterate->fileReferences,"%I64d,%I64d,%ld\n",tagReferrer,tagReferee,index);
+#else
+   fprintf (iterate->fileReferences,"%lld,%lld,%ld\n",tagReferrer,tagReferee,index);
+#endif
+}
 
-   return init_jvmti_callbacks(jvm);
+/** Local function for dealing with memory heaps... loading objects */
+void memoryWriteThreadReference(IterateControl* iterate, jlong tagReferrer, jlong tagReferee, jint index) 
+{
+#ifdef WINDOWS
+   fprintf (iterate->fileReferences,"Thread%I64d,%I64d,%ld\n",tagReferrer,tagReferee,index);
+#else
+   fprintf (iterate->fileReferences,"Thread%lld,%lld,%ld\n",tagReferrer,tagReferee,index);
+#endif
 }
 
-JNIEXPORT void JNICALL 
-Agent_OnUnload(JavaVM *jvm)
+/** Local function for dealing with memory heaps... loading objects */
+void memoryWriteObject(IterateControl* iterate, jlong objectTag, jlong classTag, jlong size) 
 {
-   printf("Unloading JBoss Profiler agent\n");
+   long longclassTag = (long)classTag;
+#ifdef WINDOWS
+   fprintf (iterate->fileObjects,"%I64d,%I64d,%I64d\n",objectTag,classTag,size);
+#else
+   fprintf (iterate->fileObjects,"%lld,%lld,%lld\n",objectTag,classTag,size);
+#endif
 }
+
+/** Local function for dealing with memory heaps... loading classes */
+void memoryWriteClass(JNIEnv *env,  jlong tag, IterateControl* iterate, jclass iterateClass) 
+{
+    char * signature;
+    char * genericPointer;
+
+    jvmtiError err = jvmti->GetClassSignature(iterateClass,&signature,&genericPointer);
+    if ( err != JVMTI_ERROR_NONE ) 
+    {
+        verifyError(err);
+        return;
+    }
+    
+    
+    jobject classLoader;
+    jvmti->GetClassLoader(iterateClass,&classLoader);
+    
+    jlong tagLoader = 0;
+    if (classLoader!=NULL) 
+    {
+	    err = jvmti->GetTag(classLoader,&tagLoader);
+	    if ( err != JVMTI_ERROR_NONE ) 
+	    {
+	        verifyError(err);
+	    }
+	}
+    
+    if (tagLoader==0 && classLoader!=NULL) 
+    {
+       tagLoader = iterate->genericCount++;
+       jvmti->SetTag(classLoader,tagLoader);
+       jlong classLoaderClassTag;
+       jclass classLoaderClass = env->GetObjectClass(classLoader);
+       jvmti->GetTag(classLoaderClass,&classLoaderClassTag);
+       jlong size;
+       jvmti->GetObjectSize(classLoaderClass,&size);
+       memoryWriteObject(iterate,tagLoader,classLoaderClassTag,size);
+    } 
+    
+    #ifdef WINDOWS
+    fprintf (iterate->fileClasses,"%10I64d,%s,%I64d\n",tag,signature,tagLoader);
+    #else
+    fprintf (iterate->fileClasses,"%lld,%s,%lld\n",tag,signature,tagLoader);
+    #endif
+    
+    
+         
+    if (signature!=NULL) jvmti->Deallocate((unsigned char *)signature);
+    if (genericPointer!=NULL) jvmti->Deallocate((unsigned char *)genericPointer);
+}
+
+JNIEXPORT jobjectArray JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getLoadedClasses
+  (JNIEnv * env, jobject thisObject)
+{
+  if (!checkJVMTI(env))
+  {
+     return NULL;
+  }
+
+  
+  jclass loadedClass = env->FindClass("java/lang/Class");
+  
+#ifdef DEBUG
+  fprintf (stderr,"LoadedClass = %ld\n",loadedClass);
+#endif
+  
+
+  jint classCount=0;
+  jclass * classesPointer;
+  
+  jvmti->GetLoadedClasses(&classCount,&classesPointer);
+  
+  // Set the object array
+  jobjectArray arrayReturn = env->NewObjectArray(classCount,loadedClass,0);
+  
+  for (jsize i=0;i<classCount;i++) {
+     env->SetObjectArrayElement(arrayReturn,i, classesPointer[i]);
+  }
+  
+  jvmti->Deallocate((unsigned char *)classesPointer);
+  
+  return arrayReturn;
+}
+
+/** Callback JVMTI function for threadReference */
+static jvmtiIterationControl JNICALL iterateThreadReference
+    (jvmtiHeapRootKind root_kind, 
+     jlong class_tag, 
+     jlong size, 
+     jlong* tag_ptr, 
+     jlong thread_tag, 
+     jint depth, 
+     jmethodID method, 
+     jint slot, 
+     void* user_data) 
+{
+     IterateControl * iterate = (IterateControl *) user_data;
+
+     if ((*tag_ptr)==0) 
+     {
+        *tag_ptr = iterate->genericCount++;
+        memoryWriteObject(iterate, *tag_ptr,class_tag,size);
+     }
+     
+     if (!class_tag)
+     {
+        fprintf (stderr,"ClassTAG can't be NULL... it happened at iterateThreadReference\n");
+     }
+#ifdef DEBUG
+     fprintf (stderr,"Thread - classTag = %ld\n",class_tag);
+#endif
+     memoryWriteThreadReference(iterate, thread_tag, *tag_ptr, 0);
+     return JVMTI_ITERATION_CONTINUE;
+}
+
+/** Callback JVMTI function for Root references */
+jvmtiIterationControl JNICALL iterateRoot (jvmtiHeapRootKind root_kind, 
+     jlong class_tag, 
+     jlong size, 
+     jlong* tag_ptr, 
+     void* user_data) 
+{
+
+     IterateControl * iterate = (IterateControl *) user_data;
+     if ((*tag_ptr)==0) 
+     {
+        *tag_ptr = iterate->genericCount++;
+        memoryWriteObject(iterate, *tag_ptr,class_tag,size);
+     }
+     
+#ifdef DEBUG
+     fprintf (stderr,"Root - classTag = %ld and class=%ld reference = %ld\n",class_tag,*tag_ptr);
+#endif
+     memoryWriteReference(iterate, 0, *tag_ptr, 0);
+     return JVMTI_ITERATION_CONTINUE;
+}
+
+/** Callback JVMTI function for Object Relationships */
+jvmtiIterationControl JNICALL iterateObjectRelationship
+    (jvmtiObjectReferenceKind reference_kind, 
+     jlong class_tag, 
+     jlong size, 
+     jlong* tag_ptr, 
+     jlong referrer_tag, 
+     jint referrer_index, 
+     void* user_data) 
+{
+     /*if (reference_kind==JVMTI_REFERENCE_CLASS ||
+         reference_kind==JVMTI_REFERENCE_CLASS_LOADER ||
+         reference_kind==JVMTI_REFERENCE_INTERFACE ||
+         reference_kind==JVMTI_REFERENCE_CONSTANT_POOL)
+         {
+                 return JVMTI_ITERATION_CONTINUE;
+         } */
+         
+    IterateControl * iterate = (IterateControl *) user_data;
+     
+     if ((*tag_ptr)==0) 
+     {
+        *tag_ptr = iterate->genericCount++;
+        memoryWriteObject(iterate, *tag_ptr,class_tag,size);
+     }
+     
+     memoryWriteReference(iterate, referrer_tag, *tag_ptr, referrer_index);
+
+#ifdef DEBUG
+//     fprintf (stderr,"Relationship between %ld and %ld\n",referrer_tag, *tag_ptr);
+     fprintf (stderr,"Relationship between %ld ",*tag_ptr);
+     fprintf (stderr,"and reftag=%ld\n",referrer_tag);
+#endif
+     return JVMTI_ITERATION_CONTINUE;
+ }
+
+jvmtiIterationControl JNICALL cleanTag
+    (jlong class_tag, 
+     jlong size, 
+     jlong* tag_ptr, 
+     void* user_data)
+{
+   *tag_ptr=0;
+   return JVMTI_ITERATION_CONTINUE;   
+}
+
+
+void releaseTags()
+{
+  jvmti->IterateOverHeap( JVMTI_HEAP_OBJECT_TAGGED,
+				  &cleanTag, NULL);
+}
+
+JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_heapSnapshot
+  (JNIEnv * env, jclass clazz, jstring classesFileName, jstring referencesFileName, jstring objectsFileName) 
+{
+
+  jint classCount=0;
+  jclass * classesPointer;
+  
+  const char * strClasses =   env->GetStringUTFChars(classesFileName,NULL);
+  const char * strReferences =   env->GetStringUTFChars(referencesFileName,NULL);
+  const char * strObjects =   env->GetStringUTFChars(objectsFileName,NULL);
+
+
+  if (!checkJVMTI(env))
+  {
+     return;
+  }
+
+  
+  IterateControl iterate;
+  iterate.genericCount=0;
+  iterate.fileObjects = fopen (strObjects,"w+");
+  if (iterate.fileObjects==NULL) {
+     fprintf (stderr,"couldn't open file %s\n",strObjects);
+     throwException(env,"java/lang/RuntimeException","Couldn't open objects file");
+     return;
+  }
+  fprintf (iterate.fileObjects,"objectTag,classTag,size\n");
+  
+  iterate.fileReferences = fopen (strReferences,"w+");
+  if (iterate.fileReferences==NULL) {
+     fprintf (stderr,"couldn't open file %s\n",strReferences);
+     throwException(env,"java/lang/RuntimeException","Couldn't open references file");
+     return;
+  }
+  fprintf (iterate.fileReferences,"tagReferrer,tagReferee,index\n");
+
+  iterate.fileClasses = fopen (strClasses,"w+");
+  if (iterate.fileClasses==NULL) {
+     fprintf (stderr,"couldn't open file %s\n",strClasses);
+     throwException(env,"java/lang/RuntimeException","Couldn't open classes file");
+     return;
+  }
+  fprintf (iterate.fileClasses,"tagClass,signature,tagClassLoader\n");
+  
+  env->ReleaseStringUTFChars(classesFileName,strClasses);
+  env->ReleaseStringUTFChars(referencesFileName,strReferences);
+  env->ReleaseStringUTFChars(objectsFileName,strObjects);
+  
+  jvmti->GetLoadedClasses(&classCount,&classesPointer);
+
+  jvmtiError    err;
+  
+  // we need to first setAllTags, to avoid dependencies between classes and classLoaders
+  for (jsize i=0;i<classCount;i++) 
+  {
+     err = jvmti->SetTag(classesPointer[i],i+1);
+    iterate.genericCount = i;
+  }
+  
+  iterate.genericCount = iterate.genericCount + 1002;
+  
+  
+  for (jsize i=0;i<classCount;i++) 
+  {
+     jlong classTag;
+     jvmti->GetTag(classesPointer[i],&classTag);
+     //err = jvmti->SetTag(classesPointer[i],i);
+     
+     if ( err != JVMTI_ERROR_NONE ) 
+     {
+        verifyError(err);
+        return;
+     }
+     
+     memoryWriteClass(env, classTag, &iterate,classesPointer[i]);
+
+  }
+  
+  jvmti->Deallocate((unsigned char *)classesPointer);
+
+  err = jvmti->IterateOverReachableObjects(iterateRoot,
+            iterateThreadReference,
+            iterateObjectRelationship,
+            &iterate);
+  verifyError(err);
+            
+  fclose(iterate.fileObjects);
+  fclose(iterate.fileReferences);
+  fclose(iterate.fileClasses);  
+
+  releaseTags();
+  
+  verifyError(err);
+}
+
+JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_forceGC
+  (JNIEnv * env, jobject thisObject)
+{
+  if (!checkJVMTI(env))
+  {
+     return;
+  }
+
+   jvmti->ForceGarbageCollection();
+}
+
+jvmtiIterationControl JNICALL iterate_getAllObjects
+    (jlong class_tag, 
+     jlong size, 
+     jlong* tag_ptr, 
+     void* user_data)
+{
+
+    IteraOverObjectsControl * control = (IteraOverObjectsControl *) user_data;
+    *tag_ptr=1;
+    control->count++;
+
+//    fprintf (stderr,"Iterate getAllObjects = %ld\n",control->count);
+    
+    return JVMTI_ITERATION_CONTINUE;
+}
+
+
+/*
+ * Class:     org_jboss_profiler_jvmti_JVMTIInterface
+ * Method:    getAllObjects
+ * Signature: (Ljava/lang/Class;)[Ljava/lang/Object;
+ */
+JNIEXPORT jobjectArray JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getAllObjects
+  (JNIEnv * env, jobject jvmtiInteface_this, jclass klass) {
+
+  if (!checkJVMTI(env))
+  {
+     return NULL;
+  }
+
+  jclass loadedObject = env->FindClass("java/lang/Object");
+  
+
+  
+  IteraOverObjectsControl control;
+  control.size = 0;
+  control.maxsize = 0;
+  control.count=0;
+
+  
+  jvmti->IterateOverInstancesOfClass(
+            klass,
+            JVMTI_HEAP_OBJECT_EITHER,
+            iterate_getAllObjects,
+            &control);
+            
+
+  jint countObjts=0;
+  jobject * objs;
+  jlong * tagResults;
+
+  jlong idToQuery=1;  
+
+  /// http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html#GetObjectsWithTags 
+  jvmti->GetObjectsWithTags(1,
+            &idToQuery,
+            &countObjts,
+            &objs,
+            &tagResults);
+  
+  // Set the object array
+  jobjectArray arrayReturn = env->NewObjectArray(countObjts,loadedObject,0);
+
+  for (jsize i=0;i<countObjts;i++) {
+     env->SetObjectArrayElement(arrayReturn,i, objs[i]);
+  }
+  
+  jvmti->Deallocate((unsigned char *)tagResults);  
+  jvmti->Deallocate((unsigned char *)objs);  
+  
+  releaseTags();            
+  
+  
+  return arrayReturn;
+}
+
+
+/** Callback JVMTI function for threadReference */
+static jvmtiIterationControl JNICALL iterateThreadReferenceLookupReference
+    (jvmtiHeapRootKind root_kind, 
+     jlong class_tag, 
+     jlong size, 
+     jlong* tag_ptr, 
+     jlong thread_tag, 
+     jint depth, 
+     jmethodID method, 
+     jint slot, 
+     void* user_data) 
+{
+	IteraOverObjectsControl * control = (IteraOverObjectsControl *)user_data;
+	
+	if (*tag_ptr==10)
+	{
+		addTag(control,thread_tag);
+	}
+	else
+	if (*tag_ptr!=10)
+	{
+		*tag_ptr=control->count++;
+	}
+
+    return JVMTI_ITERATION_CONTINUE;
+}
+
+/** Callback JVMTI function for Root references */
+jvmtiIterationControl JNICALL iterateRootLookupReference (jvmtiHeapRootKind root_kind, 
+     jlong class_tag, 
+     jlong size, 
+     jlong* tag_ptr, 
+     void* user_data) 
+{
+	IteraOverObjectsControl * control = (IteraOverObjectsControl *)user_data;
+	
+	if (*tag_ptr!=10)
+	{
+		*tag_ptr=control->count++;
+	}
+	
+     return JVMTI_ITERATION_CONTINUE;
+}
+
+/** Callback JVMTI function for Object Relationships */
+jvmtiIterationControl JNICALL iterateObjectRelationshipLookupReference
+    (jvmtiObjectReferenceKind reference_kind, 
+     jlong class_tag, 
+     jlong size, 
+     jlong* tag_ptr, 
+     jlong referrer_tag, 
+     jint referrer_index, 
+     void* user_data) 
+{
+	IteraOverObjectsControl * control = (IteraOverObjectsControl *)user_data;
+	
+	if (*tag_ptr==10)
+	{
+		addTag(control,referrer_tag);
+	}
+	else
+	if (*tag_ptr!=10)
+	{
+		*tag_ptr=control->count++;
+	}
+
+    return JVMTI_ITERATION_CONTINUE;
+ }
+
+
+
+JNIEXPORT jobjectArray JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getReferenceHolders
+  (JNIEnv * env, jobject thisObject, jobjectArray objectArray)
+{
+  if (!checkJVMTI(env))
+  {
+     return NULL;
+  }
+	jobject referencedObject;
+
+
+	jsize arrayLength = env->GetArrayLength(objectArray); 	
+	for (jsize i=0;i<arrayLength;i++)
+	{
+		referencedObject = env->GetObjectArrayElement(objectArray,i);
+		jvmti->SetTag(referencedObject,(jlong)10);
+	}
+
+    IteraOverObjectsControl control;
+	control.size = 0;
+	control.maxsize = 0;
+	control.count=1000;
+	control.tags=NULL;
+	
+    jvmtiError err = jvmti->IterateOverReachableObjects(iterateRootLookupReference,
+            iterateThreadReferenceLookupReference,
+            iterateObjectRelationshipLookupReference,
+            &control);
+            
+    jint countObjts=0;
+    jobject * objs=NULL;
+    jlong * tagResults;
+
+    jlong idToQuery=1;  
+
+    /// http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html#GetObjectsWithTags 
+    jvmti->GetObjectsWithTags(control.size,
+            control.tags,
+            &countObjts,
+            &objs,
+            &tagResults);
+    
+    // Set the object array
+    jclass loadedObject = env->FindClass("java/lang/Object");
+    jobjectArray arrayReturn = env->NewObjectArray(countObjts,loadedObject,0);
+
+    for (jsize i=0;i<countObjts;i++) {
+       env->SetObjectArrayElement(arrayReturn,i, objs[i]);
+    }
+    
+    if (control.tags!=NULL)
+    {
+    	jvmti->Deallocate((unsigned char *)control.tags);
+    }
+    jvmti->Deallocate((unsigned char *)tagResults);
+    jvmti->Deallocate((unsigned char *)objs);
+            
+	releaseTags();
+
+	return arrayReturn;
+}
+
+JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_releaseTags
+  (JNIEnv *, jobject)
+{
+	releaseTags();
+}
+
+void writeReferenceOnNotify(FILE * fileReference,jlong referenceHolder,jlong referencedObject,jlong classTag,jlong index,jmethodID method,jbyte referenceType)
+{
+	if (fileReference!=NULL)
+	{
+		fwrite((const void *) &referenceHolder,sizeof(referenceHolder),1,fileReference);
+		fwrite((const void *) &referencedObject,sizeof(referencedObject),1,fileReference);
+		fwrite((const void *) &classTag,sizeof(classTag),1,fileReference);
+		fwrite((const void *) &index,sizeof(index),1,fileReference);
+		fwrite((const void *) &referenceType,sizeof(referenceType),1,fileReference);
+		fwrite((const void *) &method,sizeof(method),1,fileReference);
+	}
+}
+
+void writeObjectOnNotify(FILE * fileReference,jlong classTag,jlong objectTag,jlong bytes)
+{
+	if (fileReference!=NULL)
+	{
+		fwrite((const void *) &classTag,sizeof(classTag),1,fileReference);
+		fwrite((const void *) &objectTag,sizeof(objectTag),1,fileReference);
+		fwrite((const void *) &bytes,sizeof(bytes),1,fileReference);
+	}
+}
+
+/** Callback JVMTI function for Root references used on notifyOnReferences*/
+jvmtiIterationControl JNICALL iterateRootOnNotify (jvmtiHeapRootKind root_kind, 
+     jlong class_tag, 
+     jlong size, 
+     jlong* tag_ptr, 
+     void* user_data) 
+{
+
+     IterateControl * iterate = (IterateControl *) user_data;
+     if ((*tag_ptr)==0) 
+     {
+        *tag_ptr = iterate->genericCount++;
+        
+        writeObjectOnNotify(iterate->fileObjects, class_tag, *tag_ptr,size);
+     }
+     
+     writeReferenceOnNotify(iterate->fileReferences,-1,*tag_ptr,0,0,NULL,10);
+     
+#ifdef DEBUG
+     fprintf (stderr,"Root - classTag = %ld and class=%ld reference = %ld\n",class_tag,*tag_ptr);
+#endif
+     return JVMTI_ITERATION_CONTINUE;
+}
+
+
+/** Callback JVMTI function for threadReference used on notifyOnReferences*/
+static jvmtiIterationControl JNICALL iterateThreadReferenceOnNotify
+    (jvmtiHeapRootKind root_kind, 
+     jlong class_tag, 
+     jlong size, 
+     jlong* tag_ptr, 
+     jlong thread_tag, 
+     jint depth, 
+     jmethodID method, 
+     jint slot, 
+     void* user_data) 
+{
+     IterateControl * iterate = (IterateControl *) user_data;
+
+     if ((*tag_ptr)==0) 
+     {
+        *tag_ptr = iterate->genericCount++;
+        writeObjectOnNotify(iterate->fileObjects, class_tag, *tag_ptr,size);
+     }
+     
+     if (!class_tag)
+     {
+        fprintf (stderr,"ClassTAG can't be NULL... it happened at iterateThreadReference\n");
+     }
+     
+#ifdef DEBUG
+     fprintf (stderr,"Thread - classTag = %ld\n",class_tag);
+#endif
+     // meed to verify this option
+     writeReferenceOnNotify(iterate->fileReferences,class_tag,*tag_ptr,class_tag,0,method,REFERENCE_THREAD);
+     return JVMTI_ITERATION_CONTINUE;
+}
+
+/** Callback JVMTI function for Object Relationships used on notifyOnReferences*/
+jvmtiIterationControl JNICALL iterateObjectRelationshipOnNotify
+    (jvmtiObjectReferenceKind reference_kind, 
+     jlong class_tag, 
+     jlong size, 
+     jlong* tag_ptr, 
+     jlong referrer_tag, 
+     jint referrer_index, 
+     void* user_data) 
+{
+     if (reference_kind==JVMTI_REFERENCE_CONSTANT_POOL)
+         {
+                 return JVMTI_ITERATION_CONTINUE;
+         }
+     /*if (reference_kind==JVMTI_REFERENCE_CLASS ||
+         reference_kind==JVMTI_REFERENCE_CLASS_LOADER ||
+         reference_kind==JVMTI_REFERENCE_INTERFACE ||
+         reference_kind==JVMTI_REFERENCE_CONSTANT_POOL)
+         {
+                 return JVMTI_ITERATION_CONTINUE;
+         } */
+         
+    IterateControl * iterate = (IterateControl *) user_data;
+    if ((*tag_ptr)==0) 
+    {
+       *tag_ptr = iterate->genericCount++;
+       writeObjectOnNotify(iterate->fileObjects, class_tag, *tag_ptr,size);
+    }
+    
+    writeReferenceOnNotify(iterate->fileReferences,
+                           referrer_tag,
+                           *tag_ptr,
+                           class_tag,
+                           referrer_index,
+                           NULL,
+                           reference_kind);
+    return JVMTI_ITERATION_CONTINUE;
+ }
+
+
+JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_notifyInventory
+  (JNIEnv *env, jobject thisObject, jboolean notifyClasses, jstring temporaryFileReferences, jstring temporaryFileObjects, jobject jvmtiCallBack)
+{
+  if (!checkJVMTI(env))
+  {
+     return;
+  }
+
+  IterateControl iterate;
+  releaseTags();
+
+  jvmtiError err;
+  if (temporaryFileReferences!=NULL)
+  {
+  	  const char * strTemporaryFile = strTemporaryFile = env->GetStringUTFChars(temporaryFileReferences,NULL);
+	  iterate.fileReferences = fopen(strTemporaryFile,"wb+");
+	  if (iterate.fileReferences==NULL) {
+             fprintf (stderr,"Couldn't open %s\n",strTemporaryFile);
+	     throwException(env,"java/lang/RuntimeException","Couldn't open references file");
+	     return;
+	  }
+      env->ReleaseStringUTFChars(temporaryFileReferences,strTemporaryFile);
+  }
+  else
+  {
+  	iterate.fileReferences = NULL;
+  }
+
+  if (temporaryFileObjects!=NULL)
+  {
+  	  const char * strTemporaryFile = strTemporaryFile = env->GetStringUTFChars(temporaryFileObjects,NULL);
+	  iterate.fileObjects = fopen(strTemporaryFile,"wb+");
+	  if (iterate.fileObjects==NULL) {
+             fprintf (stderr,"Couldn't open %s\n",strTemporaryFile);
+	     throwException(env,"java/lang/RuntimeException","Couldn't open objects file");
+	     return;
+	  }
+      env->ReleaseStringUTFChars(temporaryFileObjects,strTemporaryFile);
+  }
+  else
+  {
+  	iterate.fileObjects=NULL;
+  }
+  
+  if (!checkJVMTI(env))
+  {
+     return;
+  }
+  
+  
+  jint classCount=0;
+  jclass * classesPointer;
+  jvmti->GetLoadedClasses(&classCount,&classesPointer);
+  // we need to first setAllTags, to avoid dependencies between classes and classLoaders
+  for (jsize i=0;i<classCount;i++) 
+  {
+     err = jvmti->SetTag(classesPointer[i],i+1);
+  }
+
+  jclass clazz = env->GetObjectClass(jvmtiCallBack);
+
+  jmethodID methodNotifyClass = env->GetMethodID(clazz,"notifyClass","(JLjava/lang/Class;)V");
+  if (methodNotifyClass==NULL)
+  {
+	     throwException(env,"java/lang/RuntimeException","Method notifyClass not found on JVMTICallBack");
+	     return;
+  }
+  jmethodID notifyMethod = env->GetMethodID(clazz,"notifyReference","(JJJJJB)V");
+  if (notifyMethod==NULL)
+  {
+  	throwException(env,"java/lang/RuntimeException","Couldn't find notifyReference");
+  	return ;
+  }
+  jmethodID notifyMethodObject = env->GetMethodID(clazz,"notifyObject","(JJJ)V");
+  if (notifyMethodObject==NULL)
+  {
+  	throwException(env,"java/lang/RuntimeException","Couldn't find notifyObject");
+  	return ;
+  }
+
+  fflush(stderr);
+  iterate.genericCount=classCount + 1000;
+  jvmti->ForceGarbageCollection();
+
+
+  fflush(stderr);
+  err = jvmti->IterateOverReachableObjects(iterateRootOnNotify,
+            iterateThreadReferenceOnNotify,
+            iterateObjectRelationshipOnNotify,
+            &iterate); 
+  verifyError(err);
+  
+  if (notifyClasses)
+  {
+	  // we need to first setAllTags, to avoid dependencies between classes and classLoaders
+	  for (jsize i=0;i<classCount;i++) 
+	  {
+		    env->CallVoidMethod(jvmtiCallBack,methodNotifyClass,(jlong)(i+1),classesPointer[i]);
+	  }
+  }
+
+  jvmti->Deallocate((unsigned char *)classesPointer);
+
+
+  if (iterate.fileObjects!=NULL)
+  {
+	  fseek(iterate.fileObjects,SEEK_SET,0l); 
+	  
+	  jlong classTag=0;
+	  jlong objectTag=0;
+	  jlong bytes=0;
+	  while (!feof(iterate.fileObjects))
+	  {
+         fread((void *) &classTag,sizeof(classTag),1,iterate.fileObjects);
+         fread((void *) &objectTag,sizeof(objectTag),1,iterate.fileObjects);
+         fread((void *) &bytes,sizeof(bytes),1,iterate.fileObjects);
+	     env->CallVoidMethod(jvmtiCallBack,notifyMethodObject,classTag,objectTag,bytes);
+	  }
+	  
+  }
+
+
+  if (iterate.fileReferences!=NULL)
+  {  
+	  fseek(iterate.fileReferences,SEEK_SET,0l);
+	  jlong referenceHolder=0;
+	  jlong referencedObject=0;
+	  jlong classTag;
+	  jlong index=0;
+	  jbyte referenceType=0;
+	  jmethodID method;
+	  jlong methodParameter=0;
+	  while (!feof(iterate.fileReferences))
+	  {
+		fread((void *) &referenceHolder,sizeof(referenceHolder),1,iterate.fileReferences);
+		fread((void *) &referencedObject,sizeof(referencedObject),1,iterate.fileReferences);
+		fread((void *) &classTag,sizeof(classTag),1,iterate.fileReferences);
+		fread((void *) &index,sizeof(index),1,iterate.fileReferences);
+		fread((void *) &referenceType,sizeof(referenceType),1,iterate.fileReferences);
+		fread((void *) &method,sizeof(method),1,iterate.fileReferences);
+		// this line generates a warning due to this convertion. You can safely ignore this
+		methodParameter = (jlong)method;
+		
+	    env->CallVoidMethod(jvmtiCallBack,notifyMethod,referenceHolder,referencedObject,classTag, index,methodParameter,referenceType);
+	  }
+	            
+	  fclose(iterate.fileReferences);
+  }
+
+  verifyError(err);
+}
+
+JNIEXPORT jlong JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getTagOnObject
+  (JNIEnv * env, jobject thisObject, jobject taggedObject)
+{
+  if (!checkJVMTI(env))
+  {
+     return 0;
+  }
+    jlong retTag;
+    
+    jvmti->GetTag(taggedObject,&retTag);
+    
+    return retTag;
+}
+
+JNIEXPORT jobject JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getObjectOnTag
+  (JNIEnv * env, jobject thisObject, jlong tag)
+{
+  if (!checkJVMTI(env))
+  {
+     return NULL;
+  }
+    jint countObjts=0;
+    jobject * objs;
+    jlong * tagResults;
+    
+    if (tag<=0)
+    {
+		throwException(env,"java/lang/RuntimeException","Can't use a tag=0");
+		return NULL;
+    }
+
+    /// http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html#GetObjectsWithTags 
+    jvmti->GetObjectsWithTags(1,
+            &tag,
+            &countObjts,
+            &objs,
+            &tagResults);
+            
+    jobject retObject = NULL;
+    if (countObjts==1)
+    {
+    	retObject = objs[0];
+    }
+
+    jvmti->Deallocate((unsigned char *)tagResults);  
+    jvmti->Deallocate((unsigned char *)objs);  
+	
+	return retObject;
+}
+
+JNIEXPORT jobject JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getObjectField
+  (JNIEnv * env, jobject thisObject, jclass clazz, jboolean isStatic,jlong fieldIndex)
+{
+  if (!checkJVMTI(env))
+  {
+     return NULL;
+  }
+	jint fieldCount=0;
+	jfieldID * fields;
+	jvmtiError err = jvmti->GetClassFields(clazz,&fieldCount,&fields);
+    if ( err != JVMTI_ERROR_NONE ) 
+    {
+        verifyError(err);
+        return NULL;
+    }
+	
+    jobject field = NULL;	
+    
+	
+	if (fields!=NULL && fieldIndex<fieldCount)
+	{
+		jfieldID fieldID = fields[fieldIndex];
+	    jobject field = env->ToReflectedField(clazz,fields[fieldIndex],0);
+	}
+	
+	if (fieldCount>0 && fields!=NULL)
+	{
+		jvmti->Deallocate((unsigned char *)fields);
+	}
+	
+	return field;
+	
+}
+
+
+JNIEXPORT jstring JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getMethodName
+  (JNIEnv * env, jobject thisObject, jlong lMethodId)
+{
+  if (!checkJVMTI(env))
+  {
+     return NULL;
+  }
+	if (lMethodId==0 || lMethodId==-1) return NULL;
+	char * name;
+	jmethodID id = (jmethodID)lMethodId;
+	jvmti->GetMethodName(id,&name,NULL,NULL);
+	
+	jstring retString = env->NewStringUTF(name);
+	
+	jvmti->Deallocate((unsigned char *) name);
+	
+	return retString;
+}
+
+JNIEXPORT jstring JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getMethodSignature
+  (JNIEnv * env, jobject thisObject, jlong lMethodId)
+{
+  if (!checkJVMTI(env))
+  {
+     return NULL;
+  }
+	if (lMethodId==0 || lMethodId==-1) return NULL;
+	char * name;
+	jmethodID id = (jmethodID)lMethodId;
+	jvmti->GetMethodName(id,NULL,&name,NULL);
+	
+	jstring retString = env->NewStringUTF(name);
+	
+	jvmti->Deallocate((unsigned char *) name);
+	
+	return retString;
+}
+
+
+JNIEXPORT jclass JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getMethodClass
+  (JNIEnv * env, jobject thisObject, jlong lMethodId)
+{
+  if (!checkJVMTI(env))
+  {
+     return NULL;
+  }
+	if (lMethodId==0 || lMethodId==-1) return NULL;
+	jmethodID id = (jmethodID)lMethodId;
+	jclass retClass;
+	jvmti->GetMethodDeclaringClass(id,&retClass);
+	
+	return retClass;
+}
+
+
+JNIEXPORT jboolean JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_internalIsConfiguredProperly
+  (JNIEnv * env, jobject thisObject)
+{
+	return jvmti!=NULL;
+}
+
+JNICALL void eventMethodEntry(jvmtiEnv *jvmti_env,
+            JNIEnv* jni_env,
+            jthread thread,
+            jmethodID method)
+{
+   fprintf (stderr,"Event captured method=%ld\n", method); fflush(stderr);	
+}
+
+
+void JNICALL
+eventMethodLeave(jvmtiEnv *jvmti_env,
+            JNIEnv* jni_env,
+            jthread thread,
+            jmethodID method,
+            jboolean was_popped_by_exception,
+            jvalue return_value)
+{
+	fprintf (stderr,"Leave method=%ld\n", method);	
+}
+
+JNICALL void eventMethodLeave(jvmtiEnv *jvmti_env,
+            JNIEnv* jni_env,
+            jthread thread,
+            jmethodID method)
+{
+   fprintf (stderr,"Enter method=%ld\n", method); fflush(stderr);	
+}
+
+
+JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_startMeasure
+  (JNIEnv * env, jobject thisObj, jstring jstrDirectory, jstring jstrPrefix, jstring jstrSuffix)
+{
+  if (!checkJVMTI(env))
+  {
+     return;
+  }
+  
+  fprintf (stderr,"Start measure\n"); fflush(stderr);
+  
+  //memset(&callbacks, 0, sizeof (callbacks));
+  
+  callbacks.MethodEntry = eventMethodEntry;
+  callbacks.MethodExit = eventMethodLeave;
+  
+  jvmtiError err = jvmti->SetEventCallbacks(&callbacks, sizeof (callbacks));
+  if ( err != JVMTI_ERROR_NONE)
+  {
+      verifyError(err);
+      return;
+  }
+
+  err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, 0);
+  if ( err != JVMTI_ERROR_NONE)
+  {
+      verifyError(err);
+      return;
+  }
+  
+  err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, 0);
+  if ( err != JVMTI_ERROR_NONE)
+  {
+      verifyError(err);
+      return;
+  }
+  
+}
+
+
+

Modified: branches/JBossProfiler2/src/native/agent.h
===================================================================
--- branches/JBossProfiler2/src/native/agent.h	2009-06-24 15:17:45 UTC (rev 556)
+++ branches/JBossProfiler2/src/native/agent.h	2009-08-11 21:05:43 UTC (rev 557)
@@ -1,11 +1,35 @@
-#include <jvmti.h>
+// It requires you to include "string.h" and "io.h"
 
+
 #ifdef AGENT_MAIN
 jvmtiEnv *jvmti = NULL;
+jvmtiEventCallbacks callbacks;
 #else
 extern jvmtiEnv *jvmti;
+extern jvmtiEventCallbacks callbacks;
 #endif
 
+#define REFERENCE_ROOT 10
+#define REFERENCE_THREAD 11
+
+typedef struct _iterateControl
+{
+   FILE * fileObjects;
+   FILE * fileReferences;
+   FILE * fileClasses;
+   jlong genericCount;
+} IterateControl;
+
+typedef struct _iteraOverObjectsControl
+{
+   jint size;
+   jint maxsize;
+   jlong * tags;
+   jlong count;
+} IteraOverObjectsControl;
+
+
+
 inline void verifyError(jvmtiError error) {
    if ( error != JVMTI_ERROR_NONE ) {
       char * errorName;
@@ -13,5 +37,61 @@
       fprintf (stderr,"JVMTI Error %s\n",errorName);
       fflush(stderr);
       jvmti->Deallocate((unsigned char *)errorName);
+   }   
+}
+
+inline void addTag(IteraOverObjectsControl * control, jlong & taglong)
+{
+   if (control->size>=control->maxsize)
+   {
+      unsigned char * buffer;
+      jvmtiError error = jvmti->Allocate(sizeof(jlong) * (control->maxsize+1000),&buffer);
+      verifyError(error);
+      jlong * newbuffer = (jlong *) buffer;
+      
+      if (control->tags!=NULL)
+      {
+	      for (jint i=0;i<control->size;i++) 
+	      {
+	         newbuffer[i] = control->tags[i];
+	      }
+	      jvmti->Deallocate((unsigned char *)control->tags);
+	  }
+      control->tags = newbuffer;      
+      control->maxsize=control->size+1000;
    }
+   
+   control->tags[control->size++] = taglong;
 }
+
+void throwException(JNIEnv * env,char * clazz, char * message);
+
+jint initJVMTI(JavaVM *jvm);
+
+inline int checkJVMTI(JNIEnv * env)
+{
+   if (jvmti==NULL)
+   {
+      throwException(env,"java/lang/RuntimeException","Agent not initialized");
+      return 0;
+   }
+   
+   return 1;
+}
+
+
+inline void throwException(JNIEnv * env,char * clazz, char * message)
+{
+  jclass exceptionClass = env->FindClass(clazz);
+  if (exceptionClass==NULL) 
+  {
+     exceptionClass = env->FindClass("java/lang/RuntimeException");
+     if (exceptionClass==NULL) 
+     {
+        fprintf (stderr,"Couldn't throw exception %s - %s\n",clazz,message);
+     }
+  }
+  
+  env->ThrowNew(exceptionClass,message);
+  
+}

Added: branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java
===================================================================
--- branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java	                        (rev 0)
+++ branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java	2009-08-11 21:05:43 UTC (rev 557)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.profiler.test.jvmti;
+
+import java.net.InetSocketAddress;
+import java.util.concurrent.CountDownLatch;
+
+import org.jboss.profiler.jvmti.JVMTIInterface;
+
+/**
+ *
+ * This test has to be done manually, as it is done to validate the UI.
+ * 
+ * Add this to you VM options:
+ * 
+ * -Djava.library.path=/work/projects/prof2/src/native/ -agentpath:/work/projects/prof2/src/native/libJBossProfiler.so
+ * 
+ * Execute this test, and navigate through the interface. open http://localhost:3232
+ * 
+ * This test should stop When you press stop on the WebInterface
+ * 
+ * Look for the strings created at this test
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class JVMTIWebTestManual
+{
+   String str2[] = null;
+   String strroot;
+   
+   
+   public static void main(String arg[])
+   {
+      try
+      {
+         JVMTIWebTestManual manual = new JVMTIWebTestManual();
+         manual.testWeb();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+   
+   public void testWeb() throws Exception
+   {
+      String str[] = new String[100];
+      
+      for (int i = 0 ; i < 100; i++)
+      {
+         str[i] = "value " + i;
+      }
+      
+      
+      str2 = str;
+      
+      String strroot2 = str[0];
+      strroot = str[0];
+      
+      JVMTIInterface jvmti = new JVMTIInterface();
+      
+      CountDownLatch latch = new CountDownLatch(1);
+
+      jvmti.startMemoryProfiler(new InetSocketAddress(3232), latch);
+
+      System.out.println("Value = " + str + "  5 = " + str[5] + "  strroot = " + strroot2);
+      
+      latch.await();
+   }
+
+}




More information about the jboss-cvs-commits mailing list