OS X的System代理的JVM自动设置如何工作? [英] How does JVM automatic setting of OS X's System proxies work?

查看:69
本文介绍了OS X的System代理的JVM自动设置如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在弄乱代理设置和JVM.显然,OS X(在我的情况下为Maverics)是唯一在其上JVM(今天为1.8_92)自动应用系统首选项中设置的代理的系统.我测试过的任何其他系统(带有openbox的Arch Linux,没有Gnome/KDE,Windows 7,有一些最新的Debian版本)都没有这样做,有必要使用'-Djava.net.useSystemProxies' (适用于Windows)或使用"-Dhttp.proxyHost = ..."等明确设置代理.

我很确定应用了OS X系统代理,因为我在首选项中使用了特殊的标记"代理主机名.当我更改主机名时,JVM会将其代理设置更改为新的主机名(不过,我需要重新启动JVM,但是在JVM运行时它不会更改,但是可以).

我发现这种行为很酷(显然,代理仅在OS X上可以立即使用,在我使用其他系统遇到很多问题后,它可以刷新),但是似乎没有任何地方对此进行记录.

有人能证明神奇的是OS X上的JVM吗?它在哪里发生,由谁发生?我可以想象有多种方法可以实现这一目标:Mac的JVM可能很聪明,并且知道如何查找OS X的代理设置,或者每当网络设置发生变化时都可能写入一些配置文件,而JVM可以在启动时简单地读取它,或...很多选项,但是实际上如何工作?

解决方案

有一个调用 解决方案

There's a call to GetJavaProperties in libjava which is implementation dependent; Mac OSX shares the general Unix implementation. This is used to set up any system properties such that they are then stamped on the general Java properties such as the file system's default encoding and so forth.

There's a bit down the bottom that is conditionally included for MACOSX that calls setProxyProperties which performs the proxy lookup using the OSX standard System Configuration framework.

Once the system proxy information is known it gets passed back up through the call chain into System.c that says if the proxy information is found the standard Java system properties http.proxyPort etc. are set.

So the call stack is:

  • Java_java_lang_System_initProperties
  • GetJavaProperties
  • setProxyProperties
  • SCDynamicStoreCopyProxies <- the OSX specific call

Followed by the PUTPROP in the initProperties method if the above returns something.

这篇关于OS X的System代理的JVM自动设置如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆