#vulnerable code 
                                private static synchronized void main(final String args, final Instrumentation inst) {
        try {

//            // 传递的args参数分两个部分:agentJar路径和agentArgs
//            // 分别是Agent的JAR包路径和期望传递到服务端的参数
//            final int index = args.indexOf(";");
//            final String agentJar = args.substring(0, index);
//            final String agentArgs = args.substring(index, args.length());

            // 构造自定义的类加载器，尽量减少Greys对现有工程的侵蚀
            final ClassLoader agentLoader = new URLClassLoader(new URL[]{new URL("file:" + JARFILE)}) {

                // 这里还是放弃破坏双亲委派模型，因为接下来的编程模型太复杂
//                @Override
//                protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
//                    final Class<?> loadedClass = findLoadedClass(name);
//                    if (loadedClass != null) {
//                        return loadedClass;
//                    }
//
//                    try {
//                        Class<?> aClass = findClass(name);
//                        if (resolve) {
//                            resolveClass(aClass);
//                        }
//                        return aClass;
//                    } catch (Exception e) {
//                        return super.loadClass(name, resolve);
//                    }
//                }

            };


            // Configure类定义
            final Class<?> classOfConfigure = agentLoader.loadClass("com.github.ompc.greys.Configure");

            // GaServer类定义
            final Class<?> classOfGaServer = agentLoader.loadClass("com.github.ompc.greys.server.GaServer");

            // 反序列化成Configure类实例
            final Object objectOfConfigure = classOfConfigure.getMethod("toConfigure", String.class)
                    .invoke(null, args);

            // JavaPid
            final int javaPid = (Integer) classOfConfigure.getMethod("getJavaPid").invoke(objectOfConfigure);

            // 获取GaServer单例
            final Object objectOfGaServer = classOfGaServer
                    .getMethod("getInstance", int.class, Instrumentation.class)
                    .invoke(null, javaPid, inst);

            // gaServer.isBind()
            final boolean isBind = (Boolean) classOfGaServer.getMethod("isBind").invoke(objectOfGaServer);

            if (!isBind) {
                classOfGaServer.getMethod("bind", classOfConfigure).invoke(objectOfGaServer, objectOfConfigure);
            }

        } catch (Throwable t) {
            t.printStackTrace();
        }

    } 
                            #location 39 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                private static synchronized void main(final String args, final Instrumentation inst) {
        try {

            // 传递的args参数分两个部分:agentJar路径和agentArgs
            // 分别是Agent的JAR包路径和期望传递到服务端的参数
            final int index = args.indexOf(";");
            final String agentJar = args.substring(0, index);
            final String agentArgs = args.substring(index, args.length());

            // 构造自定义的类加载器，尽量减少Greys对现有工程的侵蚀
            final ClassLoader agentLoader = loadOrDefineClassLoader(agentJar);


            // Configure类定义
            final Class<?> classOfConfigure = agentLoader.loadClass("com.github.ompc.greys.Configure");

            // GaServer类定义
            final Class<?> classOfGaServer = agentLoader.loadClass("com.github.ompc.greys.server.GaServer");

            // 反序列化成Configure类实例
            final Object objectOfConfigure = classOfConfigure.getMethod("toConfigure", String.class)
                    .invoke(null, agentArgs);

            // JavaPid
            final int javaPid = (Integer) classOfConfigure.getMethod("getJavaPid").invoke(objectOfConfigure);

            // 获取GaServer单例
            final Object objectOfGaServer = classOfGaServer
                    .getMethod("getInstance", int.class, Instrumentation.class)
                    .invoke(null, javaPid, inst);

            // gaServer.isBind()
            final boolean isBind = (Boolean) classOfGaServer.getMethod("isBind").invoke(objectOfGaServer);

            if (!isBind) {
                classOfGaServer.getMethod("bind", classOfConfigure).invoke(objectOfGaServer, objectOfConfigure);
            }

        } catch (Throwable t) {
            t.printStackTrace();
        }

    }