小编Nic*_*ong的帖子

如何在运行时重新转换类

我正在修改已经加载到jvm中的类.我找到的解决方案是:

  • 1st将代理程序附加到pid指定的jvm.(例如8191)(代码:AttachTest)
  • 2从已经加载到jvm中的类(例如8191)中查找要修改的类.
  • 3使用仪器添加变压器(代码:AgentMain)
  • 4修改方法中的类(例如Person)transform(代码:DemoTransformer)
  • 5th使用retransformClasses重新转换

从第1步到第5步工作正常,但是有问题retransformClasses.它transform再次调用,其中包含修改类的代码.它修改了我从不想修改的其他类.我认为问题可能发生在addTransformer或期间retransformClasses.但我还是很困惑.那么,如何重新转换一个类?有任何想法吗?谢谢

public class AttachTest {
    public static void main(String[] args) throws AttachNotSupportedException,
        IOException, AgentLoadException, AgentInitializationException { 
        String agentPath = "D:\\work\\workspace\\myjar\\loaded.jar";
        String vid = args[0]; 
        VirtualMachine vm = VirtualMachine.attach(vid);
        vm.loadAgent(agentPath);
    }
}
Run Code Online (Sandbox Code Playgroud)

//代理

public class AgentMain {
    public static void agentmain (String agentArgs, Instrumentation inst)
        throws ClassNotFoundException, UnmodifiableClassException,
        InterruptedException {
    Class<?> [] allLoadedClasses = inst.getAllLoadedClasses();
        String tmpString = null;
        for (int …
Run Code Online (Sandbox Code Playgroud)

java aop jvm cglib

35
推荐指数
1
解决办法
2万
查看次数

如何在命令中从ntp时间服务器同步窗口时间

我正在使用Windows 7.我可以手动从ntp linux服务器同步win7的时间.我怎么能在命令提示符下执行此操作.所以我可以在Windows启动时运行它.Windows任务计划对我不起作用.时间应该是这样的:

Linux server -->  windows 7.
Run Code Online (Sandbox Code Playgroud)

谁知道呢?谢谢.我可以阅读msdn.

windows time ntp

32
推荐指数
4
解决办法
26万
查看次数

什么是gcc选项"-fmessage-length"?

我正在使用CDT(eclipse用于c语言).我发现默认的gcc编译器选项是-O0 -g3 -Wall -c -fmessage-length=0.是什么意思-fmessage-length?应该是-fflag,但那怎么样message-length?我没有在GCC命令行选项中找到它.谢谢你的考虑.

c c++ compiler-construction gcc

26
推荐指数
2
解决办法
1万
查看次数

如何使用Django清除cookie

我正在尝试为网站开发登录页面.我正在使用Django 1.4.2.我使用了正确登录cookie的用户set_cookie.但我没有clear_cookie在Django的文档中找到.如何清除cookie以使用户注销?

python django cookies session-cookies web

17
推荐指数
2
解决办法
2万
查看次数

如何使用espresso从textview获取文本

我想在LinearLayout的textview中显示文本字符串.能浓缩咖啡吗?如果没有,还有其他方法可以做到这一点,还是我可以在espresso测试用例中使用android api?我使用的是API 17 18或更新的espresso 1.1(它应该是最新的.).我对此毫无头绪.谢谢.

automated-tests android-testing android-espresso

17
推荐指数
2
解决办法
2万
查看次数

从data.frame创建条形图

在RI中有一个data.frame,就像图片顶部的那个.

是否有可能创建一个像图像底部那样的条形图?

在此输入图像描述

plot r dataframe

15
推荐指数
2
解决办法
4万
查看次数

睡眠功能是睡眠所有线程还是只调用它的人?

我在linux(Centos)上用pthread编程?我想线程睡一会儿等待一些事情.我正在尝试使用sleep(),nanosleep()或者usleep(),或者也许可以做到这一点.我想问一下:睡眠功能是睡眠所有线程还是只是调用它的人?任何建议或参考将不胜感激.

void *start_routine () {
    /* I just call sleep functions here */
    sleep (1); /* sleep all threads or just the one who call it? 
                  what about nanosleep(), usleep(), actually I 
                  want the threads who call sleep function can 
                  sleep with micro-seconds or mili-seconds.  
               */
    ...
}

int main (int argc, char **argv) {
    /* I just create threads here */
    pthread_create (... ...);
    ...
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我的测试程序:

#define _GNU_SOURCE
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <sched.h> …
Run Code Online (Sandbox Code Playgroud)

c multithreading sleep pthreads thread-sleep

7
推荐指数
2
解决办法
3万
查看次数

adb -s emu geo fix不能使用telnet工作

我的应用适用于Google Apis 17.我想在启动模拟器后设置gps位置.

我尝试按照如何模拟-ps-location-in-the-android-emulator.

1.获取模拟器的序列号.

>adb devices
emulator-5554
Run Code Online (Sandbox Code Playgroud)

第二轮

adb -s emulator-5554 emu geo fix 121.4961236714487 31.24010934431376
Run Code Online (Sandbox Code Playgroud)

没有警告和错误.我在windows7上编程.

它不起作用.但是当我在eclipse(ADT22.6)中手动发送gps信息时,它可以工作.我的应用可以正确找到位置.eclipse做了什么?如何使adb命令工作?谢谢

eclipse gps android adb android-emulator

7
推荐指数
1
解决办法
5145
查看次数

Chrome无法使用chromedriver2.9在CentOS上启动

环境:chromedriver 2.9,google-chrome-stable 34,python 2.6,CentOS6.4 final x86_64

我按照install-chrome.sh安装google-chrome-stable(不是chrome).它可以从fedoraproject中提取包并安装这些包/opt/google/chrome/lib.我安装了chromedriver2.9关注链接.我可以手动运行google-chrome和chromedriver而不会出错.我安装了硒pip install selenium(硒2.41).Selenium安装到/usr/lib/python2.6/site-packages/.以这种方式安装的Google Chrome似乎不允许以root身份打开.

当我在非root用户的python控制台下运行代码时如下:

>>> from selenium import webdriver
>>> driver = webdriver.Chrome()
Run Code Online (Sandbox Code Playgroud)

它返回错误消息,而不是打开chrome.

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 65, in __init__
    keep_alive=True)
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 72, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 115, in start_session
    'desiredCapabilities': desired_capabilities,
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 166, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 164, in check_response
    raise exception_class(message, …
Run Code Online (Sandbox Code Playgroud)

selenium google-chrome centos google-chrome-devtools selenium-chromedriver

7
推荐指数
1
解决办法
3195
查看次数

将push_back()"new"作为一个对象添加到c ++中的std :: list之前

我是c ++标准库的新手.我想使用std :: list.我知道如果我自己创建一个列表而不是使用stl,我应该将内存分配给一个新对象,然后将其添加到列表中.

一个C风格的A类清单:

A *ptrA = new A();     
ptrA->setElement(value);
ptrA->next = null;
currentPositionMyCstyleList->next = ptrA;
ptrA->prev = currentPositionMyCstyleList;
Run Code Online (Sandbox Code Playgroud)

如果我使用stl,是否有必要"新"一个对象?将push_back()"new"作为一个对象添加到c ++中的std :: list之前?

代码如下正确吗?

A aObj(value);     
listA.push_back(aObj); // Will push_back() "new" an object and copy the value of aObject to the object before add it to list
Run Code Online (Sandbox Code Playgroud)

aObj的值是否会在下面的代码中发布:

funcAddToList() {
    A aObj(value);     
    listA.push_back(aObj);
}
funcDispList() {
    // display listA  // Does the value of aObj still in list?
}
Run Code Online (Sandbox Code Playgroud)

push_back()实际上做了什么?

读完stl_list.h_push_back() ,_ M_insert,_M_create_node后我仍然感到 …

c++ gcc stl c++11

6
推荐指数
1
解决办法
1414
查看次数