Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Services #98

Merged
merged 7 commits into from
Nov 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions make/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<property name="maven-staging-repository-id" value="sonatype-nexus-staging" />
<property name="maven-staging-repository-url" value="https://oss.sonatype.org/service/local/staging/deploy/maven2" />

<property name="agent.excludes" value="**/dtrace/* **/btrace/*.class **/asm/signature/** **/asm/tree/** **/asm/util/** **/asm/xml/** **/aggregation/* **/annotations/* **/compiler/* **/client/* **/comm/* **/api/**/* **/spi/**/* **/instr/** **/META-INF/*"/>
<property name="boot.excludes" value="**/dtrace/* **/agent/* **/compiler/* **/client/* **/resources/* **/runtime/* **/util/**/* **/asm/** **/api/**/* **/spi/**/*"/>
<property name="agent.excludes" value="**/dtrace/* **/btrace/*.class **/asm/signature/** **/asm/tree/** **/asm/util/** **/asm/xml/** **/aggregation/* **/annotations/* **/compiler/* **/client/* **/comm/* com/sun/btrace/api/**/* com/sun/btrace/spi/**/* **/instr/** **/META-INF/*"/>
<property name="boot.excludes" value="**/dtrace/* **/agent/* **/compiler/* **/client/* **/resources/* **/runtime/* **/util/**/* **/asm/** com/sun/btrace/api/**/* com/sun/btrace/spi/**/*"/>
<property name="client.excludes" value="**/runtime/* **/agent/* **/util/TimeStamp* **/util/MethodId **/util/SamplingSupport **/util/templates/**/* **/instr/** **/META-INF/*"/>

<target name="prepare" depends="load.properties">
Expand Down Expand Up @@ -294,7 +294,7 @@
</copy>
</target>

<target name="build-traces" depends="jar">
<target name="build-traces" depends="jar, compile-tests">
<echo>executing ${bin.dir}/${btracec} -cp ${build.dir}/test -d ${tests.dir} ${traces.dir}/*.java</echo>
<apply executable="${bin.dir}/${btracec}" verbose="true" failonerror="true">
<fileset dir="${traces.dir}" includes="**/*.java"/>
Expand Down
52 changes: 52 additions & 0 deletions src/share/classes/com/sun/btrace/annotations/Injected.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.btrace.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Annotates a field as an injected service.
* @author Jaroslav Bachorik
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.CLASS)
public @interface Injected {
/**
* The injected service type
* @return
*/
ServiceType value() default ServiceType.SIMPLE;
/**
* The factory method to be used.
* <p>
* It must be a static method declared by the service class
* and returning the service class instance
* @return The name of the static method to be used as the factory method or an empty string
*/
String factoryMethod() default "";
}
42 changes: 42 additions & 0 deletions src/share/classes/com/sun/btrace/annotations/ServiceType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.btrace.annotations;

import com.sun.btrace.BTraceRuntime;

/**
* Service type enumeration
* @author Jaroslav Bachorik
*/
public enum ServiceType {
/**
* A simple service; possibly a globally shared singleton
*/
SIMPLE,
/**
* A runtime-aware service; requires an instance per {@linkplain BTraceRuntime}
*/
RUNTIME
}
30 changes: 13 additions & 17 deletions src/share/classes/com/sun/btrace/compiler/Postprocessor.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2008-2010 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
Expand All @@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package com.sun.btrace.compiler;
Expand All @@ -45,7 +45,7 @@
* @author Jaroslav Bachorik
*/
public class Postprocessor extends ClassVisitor {
private List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>();
private final List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>();
private boolean shortSyntax = false;
private String className = "";

Expand Down Expand Up @@ -90,24 +90,20 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
@Override
public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) {
if (!shortSyntax) return super.visitField(access, name, desc, signature, value);

final List<Attribute> attrs = new ArrayList<Attribute>();
return new FieldVisitor(Opcodes.ASM4) {

public AnnotationVisitor visitAnnotation(String string, boolean bln) {
return new AnnotationVisitor(Opcodes.ASM4){
};
}

public void visitAttribute(Attribute atrbt) {
super.visitAttribute(atrbt);
attrs.add(atrbt);

}

public void visitEnd() {
FieldDescriptor fd = new FieldDescriptor(access, name, desc,
signature, value, attrs);
fields.add(fd);
super.visitEnd();
}
};
}
Expand Down Expand Up @@ -350,7 +346,7 @@ public void visitInsn(int opcode) {
simulatedStack.push(Boolean.FALSE);
break;
}

// one operand instructions
case Opcodes.INEG:
case Opcodes.FNEG:
Expand All @@ -373,7 +369,7 @@ public void visitInsn(int opcode) {
simulatedStack.push(Boolean.FALSE); // extending the original value by one slot
break;
}

// two operand instructions
case Opcodes.LADD:
case Opcodes.DADD:
Expand All @@ -390,7 +386,7 @@ public void visitInsn(int opcode) {
case Opcodes.LUSHR:
case Opcodes.LAND:
case Opcodes.LOR:
case Opcodes.LXOR:
case Opcodes.LXOR:
case Opcodes.LALOAD:
case Opcodes.DALOAD: {
simulatedStack.pop();
Expand Down
Loading